問題描述
在所有其他非 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!
這篇關于IE https CORS XHR 請求因 Script7002 失敗:XMLHttpRequest:網絡錯誤 0x2eff的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!