I initially set out to learn how to handle “ajax-ready file uploads”; I found, and comprehend, one of the main concepts: it’s not possible as ajax, but you can submit a form with the target set to a hidden iFrame’s id [1]. That seems to be generally accepted by the community and compatible with all browsers. Is that an accurate assessment?
My question is: what are the pitfalls to this approach? Because if there are none, it seems to me that every “ajax-ready post” could be done in this same fashion. Remove the file upload component and this approach versus, say, a jQuery.post() approach appear to have identical outcomes.
In all the questions and resources I’ve researched, I’ve only been able to find “solutions” for handling my initial issue. I’ve been unable to find any sort of “pro v. con list” or “pitfalls to this approach” anywhere regarding a form targeting an iFrame; if you know of one, please feel free to share it!
[1] HTML Example:
<form method="post" target="take_the_reload">
...
</form>
<iframe class="hide_me" id="take_the_reload" name="take_the_reload"></iframe>
Much obliged,
Beez
References: Just a couple of the resources I’ve used:
- http://www.joshclarkson.net/blog/file-uploads-in-a-hidden-iframe-using-jquery/
- Firefox form targetting an iframe is opening new tab
- http://terminalapp.net/submitting-a-form-with-target-set-to-a-script-generated-iframe-on-ie/
- javascript: submit form in an iframe…help
- http://www.openjs.com/articles/ajax/ajax_file_upload/
When I first started AJAX (before jQuery and Prototype came along) I used to do exactly that with all my forms….just post them to a hidden Iframe. It was easy and painless.
The drawbacks of form-post: