[英]Internet Explorer 9- X Domain Request only works in compatability mode
We discovered our ajax call to a JSON resouce wasn't working in IE9, and that we had to use the X Domain Request API. 我们发现对JSON资源的ajax调用在IE9中不起作用,并且我们不得不使用X域请求API。 But my call is simply not calling the "onload" function unless the browser is set to compatibility mode- which is not an option.
但是,除非将浏览器设置为兼容模式,否则我的电话就是不调用“ onload”功能,这不是一个选择。
var xdr = new XDomainRequest(); // Use Microsoft XDR
xdr.open('get', uri);
xdr.onload = function () {
//debugger;
var JSON = $.parseJSON(xdr.responseText);
if (JSON == null || typeof (JSON) == 'undefined') {
JSON = $.parseJSON(data.firstChild.textContent);
}
ieCallback(JSON);
};
xdr.onerror = function () {
_result = false;
};
xdr.send();
Issue was caused by an apparent bug in IE9 which was causing XDR calls to abort. 问题是由IE9中的一个明显错误引起的,该错误导致XDR调用中止。 The solution was to overwrite the default xdr.onprogress method with an empty function:
解决的办法是用一个空函数覆盖默认的xdr.onprogress方法:
xdr.onprogress = function () { };
This helpful blog post by Perry Mitchell found the problem. 佩里·米切尔(Perry Mitchell)的这篇有用的博客文章发现了这个问题。 It's interesting that it was aborting every time except in compatability mode- maybe the timeout was being effected by the fact I was running IE9 in a virtual machine.
有趣的是,除兼容模式外,每次都异常终止-可能是由于我在虚拟机中运行IE9的事实而导致超时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.