ajax – IE9 JSON数据到iframe:“你想打开还是保存这个文件?”

前端之家收集整理的这篇文章主要介绍了ajax – IE9 JSON数据到iframe:“你想打开还是保存这个文件?”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有同样的问题 as is explained here,简而言之:

我正在使用iframe将文件发布到服务器AJAX样式,然后接收JSON响应以告诉我文件是否已成功上载和解析.除了IE9之外,每个浏览器都很棒.相反,IE9提示我保存或打开JSON,并且不会将其传递回iframe.

在另一个SO问题中,EricLaw -MSFT建议将内容类型设置为“application / json”,这是我所做的,但无济于事.

有谁知道如何让IE9让iframe拥有它的JSON?

解决方法

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.

参考

> XDomainRequest – Restrictions,Limitations and Workarounds
> HTML Living Standard: Association of controls and forms – The enctype and formenctype content attributes

猜你在找的Ajax相关文章