Parsing xml/json response in IE9

℡╲_俬逩灬. 提交于 2019-12-02 05:07:57

This is due to the Cross-domain security, called Same Origin Policy.

This plugin uses the File API if it's implemented by the browser (as in Chrome for example) and, if not, it uses a neat trick of creating a hidden iframe and posting data to it. In the case of the address being on another domain, the plugin can't get the data from the iframe, so it fail.

Try enabling the debug mode of the plugin with: $.fn.ajaxSubmit.debug = true; and you will see what is happening behind the scenes.

Unfortunataly, the only way of doing the upload is by using a hidden iframe in your HTML, not added by script, and force the post to it by passing the parameter iframeTarget with the selector for this iframe, but you will not be able to grab the response, because of the above mentioned problem (I don't know why the iframe generated by the plugin don't post the data):

JS:

$('#uploadForm').ajaxForm({
    iframeTarget: ($.browser.msie) ? "#iframeTarget" : false,
    ...

HTML:

<iframe name="iframeTarget" id="iframeTarget">This iframe can be hidden with CSS</iframe>

You can also make use of conditional comments to hide the iframe from other browsers:

<!--[if IE]>
<iframe name="iframeTarget" id="iframeTarget">This iframe can be hidden with CSS</iframe>
<![endif]-->

A note on this is that the success callback will not fire.

Edit:

Has this site you are communication with a JSON response option?

If it has, you can use jsonp as the dataType parameter, add ?callback=someFunction to the end of the url and write the someFunction(data){} that receives the data and parses it the same way your success callback.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!