ajax IE https CORS XHR 请求失败,出现 Script7002: XMLHttpRequest: Network Error 0x2eff

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25922043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 10:26:12  来源:igfitidea点击:

IE https CORS XHR request fails with Script7002: XMLHttpRequest: Network Error 0x2eff

ajaxinternet-explorerhttpsxmlhttprequestcors

提问by senor_bacon

In all other non-IE browsers, the following code snippet works great:

在所有其他非 IE 浏览器中,以下代码片段效果很好:

<!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>

In two different IE11 browsers (running on different OS versions), I get two different errors:

在两个不同的 IE11 浏览器(在不同的操作系统版本上运行)中,我收到两个不同的错误:

  1. IE11 Win7: Script7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
  2. IE11 Win8: Script7002: XMLHttpRequest: Network Error 0x2eff Could not complete the operation due to error 00002eff
  1. IE11 Win7:Script7002:XMLHttpRequest:网络错误 0x80070005,访问被拒绝。
  2. IE11 Win8: Script7002: XMLHttpRequest: Network Error 0x2eff 由于错误 00002eff 无法完成操作

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.

谷歌搜索上述错误代码没有发现任何有用的信息。我试过设置 Content-Type,为 onprogress 和 onload 添加虚拟函数,但无济于事。

采纳答案by senor_bacon

Figured it out.

弄清楚了。

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.

在我们的案例中,在之前的项目中,我们更改了 IE 允许使用的 SSL 协议。Ajax 请求失败,因为不允许 IE 根据自定义配置协商 SSL 握手。

Solution was to open up Internet Options, choose the Advanced tab, and then click the "Restore Advanced Settings" button. After that the Ajax requests worked fine.

解决方法是打开 Internet 选项,选择高级选项卡,然后单击“还原高级设置”按钮。之后,Ajax 请求工作正常。

Hopefully this saves someone else the 6 hours or so I spent on this!

希望这可以为其他人节省 6 个小时左右的时间!