Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE9 JSON Data To Iframe: "Do You Want To Open or Save This File?"

I have the same issue as is explained here, in short:

I am using an iframe to post files to the server AJAX-style, then receiving a JSON response to tell me if the file was uploaded and parsed successfully. This works great is every browser except IE9. Instead, IE9 prompts me to save or open the JSON, and will not pass it back to the iframe.

In the other SO question for this, EricLaw -MSFT suggested to set the content type to "application/json", which I have done, but to no avail.

Does anyone know how to get IE9 to let the iframe have its JSON?

like image 564
lafncow Avatar asked Dec 29 '11 17:12

lafncow


1 Answers

Well it looks like setting content type to "text/html" does the trick. It's less than ideal since it's not descriptive of the content, but oh well. Hope this helps someone else too.

HTML Forms are limited to sending data in three different content types: text/plain, application/x-www-form-urlencoded, and multipart/form-data

To workaround this issue, server code that currently processes HTML Forms must be rewritten to manually parse the request body into name-value pairs when receiving requests from XDomainRequest objects. This makes adding support for the XDomainRequest object more difficult than it would be otherwise.

References

  • XDomainRequest - Restrictions, Limitations and Workarounds

  • HTML Living Standard: Association of controls and forms - The enctype and formenctype content attributes

like image 110
3 revs Avatar answered Oct 27 '22 20:10

3 revs