jQuery iFramer is a plugin made to submit forms with a hidden iframe. Say for instance you have an Impromptu popup that contains a few form fields and a file upload. The file upload is the kicker to needing such a plugin, since you can’t upload files via old fashion ajax. Well using a simple hidden iframe and a target on our form we can submit our form into this iframe, sending the file and all. Here might be your form:
<form action="/some/url/post/" method="post" id="myform">
<input type="text" name="somethin1" value="bla bla" />
<input type="file" name="somethin1" value="bla bla" />
<input type="submit" name="somethin1" value="bla bla" />
</form>
Now with our handy plugin all we need to do is tell it to use an iframe, and we’re set:
$('#myform').iframer({
onComplete: function(data){
alert(data); //returned data
}
});
Pretty simple. There is also an option “iframe” which takes a string for the name and id to give the iframe(just incase you need to specify, doubt you ever do). This also might be an easy replacement for swf uploaders, although it doesn’t offer near the features, and never will. The good thing is you can easily send your entire form and not just the file upload(with swf uploaders) or just the text inputs(with standard ajax). This is the very first release, so use at your own risk. The source is very small so if you have any suggestions feel free to go ahead and make the changes while you’re at it! :)
You can download jQuery iFramer here.


12 Responses
anonymous
Jun 22, 2009works like a charm! thanks!
Aurélio
Sep 21, 2009can you do a live demo? thanks!
trent
Sep 23, 2009I’ve just posted a demo.
http://trentrichardson.com/2009/09/23/a-nice-clean-jquery-iframer-example/
D
Oct 16, 2009Perfect, thanks Trent. Simple and elegant.
Michele ESERVERS
Oct 20, 2009Dear Trend Richard
Sorry but I have test your script and does not work like you said!
Here it’s an example and correct me WITH A WORKING VERSION IF YOU’RE ABLE!!!
This is a simple script to upload images!
index.php
_________________________
$(‘#myform’).iframer({
onComplete: function(data){
alert(data); //returned data
}
});
________________________
request.php
________________________
<?php
if (!move_uploaded_file($_FILES['mona']['tmp_name'], 'images/'. "image1.jpg")) {
$msg = "Errore nel caricamento dell’immagine!!”;
break;
}
?>
_______________________________
Michele ESERVERS
Oct 20, 2009ADD this to index.php because this blog at first post delete it
Feroze
Nov 12, 2009sorry but Its not work….
it is really a poor example.
trent
Nov 12, 2009There is an actual example on this page:
http://trentrichardson.com/2009/09/23/a-nice-clean-jquery-iframer-example/
ClubPenguinCheats
Apr 06, 2010It works like a charm! LOL
Martin L
Jul 30, 2010Hello Trent! This works perfectly for me. Thank you very much.
/Martin
manoj
Feb 21, 2012can we show progress bar with this plugin?
trent
Feb 21, 2012Chances are no.. I’ve not done this before. It is simply a form post however into an iframe window. I’m honestly not sure if there is a way to hook in to a form submit and determine a %..