Researching: Form targeting an iFrame to submit

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 …

via HTML Language Development » Search Results » ajax:

Researching: Form targeting an iFrame to submit

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:


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:
It’s not really “pure” AJAX (file uploads aside). I’m sure all the DOM manipulation in the iframe for the result is slower than just getting back a response via XHR.
The error handling is more difficult – you have to look at what the server puts in the Iframe as a result
Things are moving towards JSON-based data handling which forms alone don’t do
Sometimes you want to do something “in the middle” between the form and the server such as some field mapping or including other client-side data

For more info: Researching: Form targeting an iFrame to submit

HTML Language Development » Search Results » ajax

Researching: Form targeting an iFrame to submit

Share this post:

Related Posts

Leave a Comment