I noticed I never provided a clean and simple example for jQuery iFramer other than posting a snipplet of code. I’ve thrown that snipplet into an actual working document to show it in action. Take a peek. Keep in mind the real reason for this plugin is to upload files easily with an “ajax” feel, but without flash. I think it works pretty well considering the small amount of code that it actually uses.
Here is our form which we want to submit:
<form action="/some/url/post/" method="post" id="myform">
<input type="text" name="somethin1" value="bla bla" />
<input type="text" name="somethin2" value="Some More.." />
<input type="submit" name="somethin1" value="Send It!" />
</form>
Then lets get some iFramer magic tied to the form:
$('#myform').iframer({
onComplete: function(data){
alert(data); //returned data
}
});
The php file which it posts to is pretty darn simple:
<?php
echo "field 1: ". $_REQUEST['somethin1'] ."\nfield 2: ". $_REQUEST['somethin2'];
?>
This could optionally be your file upload code. I didn’t show that functionality simply because I prefer not to have random users uploading things to my server :) Enjoy!
Related posts:


5 Responses
S-Article
29|Dec|2009 1I’m not jquery fun. However i had a small project which leads me to this page and to others but this little piece of code, helped me to solve my problem. I’ve made some small changes to it. However i didn’t undertand what’s with the “data” this is coming from php or how?
trent
30|Dec|2009 2“data” is the content output by the php (or whatever type page is posted to).
Stile
05|Apr|2010 3First of all, thank you because the plugin submits the file data fine. The main problem is that the message from the server is display in a different page which for me defeats the whole purpose. How do you display the message from the server in the same form page?
trent
06|Apr|2010 4The message returned by the page submit should be in the first parameter of the callback function
dfsaas
08|Jun|2010 5hdfuqwenmnx
Leave a reply