IE https CORS XHR 请求因 Script7002 失败:XMLHttpRequest:网络错误 0x2eff
在所有其他非 IE 浏览器中,以下代码片段效果很好:
In all other non-IE browsers, the following code snippet works great:
<!DOCTYPE html>
<html>
<script type="text/javascript">
var xhr = new XMLHttpRequest();
var url = "https://otherdomain.com";
var method = "GET";
xhr.open(method, url, true);
xhr.onload = function() {
var responseText = xhr.responseText;
document.write(responseText);
};
xhr.send()
</script>
</html>
在两个不同的 IE11 浏览器(在不同的操作系统版本上运行),我得到两个不同的错误:
In two different IE11 browsers (running on different OS versions), I get two different errors:
- IE11 Win7:Script7002:XMLHttpRequest:网络错误 0x80070005,访问被拒绝.
- IE11 Win8: Script7002: XMLHttpRequest: Network Error 0x2eff 由于错误 00002eff 无法完成操作
Google 搜索上述错误代码并没有找到任何有用的信息.我尝试设置 Content-Type,为 onprogress 和 onload 添加虚拟函数,但无济于事.
Google searches for the above error codes don't turn up anything useful. I've tried setting Content-Type, adding dummy functions for onprogress and onload, to no avail.
推荐答案
想通了.
在我们的案例中,在之前的项目中,我们更改了 IE 允许我们使用的 SSL 协议.Ajax 请求失败,因为不允许 IE 根据自定义配置协商 SSL 握手.
In our case, on a previous project we had changed which SSL protocols were allowed by IE to us. Ajax requests were failing because IE was not allowed to negotiate the SSL handshakes based on the custom configuration.
解决方案是打开 Internet 选项,选择高级"选项卡,然后单击恢复高级设置"按钮.之后,Ajax 请求运行良好.
希望这可以节省我花在这上面的 6 个小时左右的时间!
Hopefully this saves someone else the 6 hours or so I spent on this!
相关文章