javascript IE11 在 Ajax POST 操作期间从 iFrame 返回状态 0(XMLHttpRequest:网络错误 0x2ee4)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23820444/
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
IE11 returns status 0 during Ajax POST operation from an iFrame (XMLHttpRequest: Network Error 0x2ee4)
提问by nikoniko
It seems that IE11 version 11.0.7 (KB2929437 on Win7, KB2919355 on Win 8.1) has a problem when performing an Ajax POST operation. The operation returns status 0 and on an F12 console, the following error appears:
IE11 版本 11.0.7(Win7 上的 KB2929437,Win 8.1 上的 KB2919355)在执行 Ajax POST 操作时似乎有问题。该操作返回状态 0,在 F12 控制台上,出现以下错误:
SCRIPT7002: XMLHttpRequest: Network Error 0x2ee4, Could not complete the operation due to error 00002ee4.
The conditions to reproduce this issue are as follows:
重现此问题的条件如下:
- Happens only on specific IE11, i.e. version 11.0.7 (KB2929437 on Win7, KB2919355 on Win 8.1)
- iframe is used to load external page with https protocol (parent page is using http protocol)
- ajax with method 'POST' is used
- More frequently happens with Connection: Keep-Alive header set on by IIS
- More frequently happens on Win32 version of IE11
- 仅在特定 IE11 上发生,即版本 11.0.7(Win7 上为 KB2929437,Win 8.1 上为 KB2919355)
- iframe 用于加载带有 https 协议的外部页面(父页面使用的是 http 协议)
- 使用带有方法“POST”的 ajax
- IIS 设置的 Connection: Keep-Alive 标头更常发生
- 在 IE11 的 Win32 版本上更频繁地发生
I created the following jsfiddle to reproduce this issue: http://jsfiddle.net/VJ2D6/12/
我创建了以下 jsfiddle 来重现这个问题:http: //jsfiddle.net/VJ2D6/12/
$(document).ready(function () {
$('#frame').attr('src', 'https://54.249.142.247/ie11/test.html');
});
Please note that the iframe retrieves its source from another site 54.249.142.247 (hosted by EC2 node using IIS7), because jsfiddle doesn't host https. And, because I am using Self-Sign SSL Certificate, please first install the certificate to the Trusted Root, and turn off "Warn about certificate address mismatch" from Internet Options - Advanced Tab.
请注意,iframe 从另一个站点 54.249.142.247(由使用 IIS7 的 EC2 节点托管)检索其源,因为 jsfiddle 不托管 https。而且,因为我使用的是自签名 SSL 证书,请先将证书安装到受信任的根目录,然后从 Internet 选项 - 高级选项卡中关闭“关于证书地址不匹配的警告”。
Inside 54.249.142.247/ie11/test.html, I created a button which initiates an Ajax POST operation to a non-existing location. Normally this request should return status 404 error (Not found). But in case of IE11 version 11.0.7, it often returns status 0 error and shows Network Error 0x2ee4 inside F12 console, "
在 54.249.142.247/ie11/test.html 中,我创建了一个按钮,用于向不存在的位置启动 Ajax POST 操作。通常此请求应返回状态 404 错误(未找到)。但是在 IE11 版本 11.0.7 的情况下,它经常返回状态 0 错误并在 F12 控制台内显示网络错误 0x2ee4,“
I posted the same issue to Microsoft Connect here: https://connect.microsoft.com/IE/feedback/details/877525/ie11-returns-status-0-during-ajax-post-operation-from-an-iframe-xmlhttprequest-network-error-0x2ee4#tabs
我在这里向 Microsoft Connect 发布了同样的问题:https: //connect.microsoft.com/IE/feedback/details/877525/ie11-returns-status-0-during-ajax-post-operation-from-an-iframe- xmlhttprequest-network-error-0x2ee4#tabs
I think this is an IE11 bug, but I am not 100% sure and there is no confirmation yet from the IE team. Please help me to confirm whether this is an IE bug, or if there is any problem in my JavaScript code.
我认为这是一个 IE11 错误,但我不是 100% 确定,IE 团队还没有确认。请帮我确认这是否是 IE 错误,或者我的 JavaScript 代码是否有任何问题。
UPDATE:
更新:
Microsoft said that they can reproduce the problem and will investigate it.
微软表示他们可以重现该问题并将对其进行调查。
回答by Daniel Melo
This error is be cause a ssl certificate is invalid. For solve this error see: [Link]
此错误是因为 ssl 证书无效。要解决此错误,请参阅:[链接]
$.get(window.api + 'Values', null, null).done(function () {//solution for IE shit
$.ajax({
type: 'POST',
url: https://api.yourdomain.com,
data: yourData,
success: function (data) {
//do something
},
});
});
回答by Eduardo Alvarez
I was having the same issue when trying to do a POST call to our HTTPS WCF service (CORS) and looks like it's because of the SSL Certificate. I had to recreate mine with the following MakeCert Command line
我在尝试对我们的 HTTPS WCF 服务 (CORS) 进行 POST 调用时遇到了同样的问题,看起来是因为 SSL 证书。我必须使用以下 MakeCert 命令行重新创建我的
makecert.exe -r -pe -n "CN=*.YourDomain.com" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -a sha256 -sy 12 "C:\EncryptionCert.cer"
makecert.exe -r -pe -n "CN=*.YourDomain.com" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -a sha256 -sy 12 "C:\EncryptionCert.cer"
installed the created Cert into Client and server trusted root cert Auth.
将创建的证书安装到客户端和服务器信任的根证书 Auth 中。
After choosing this cert for my Site binding, I was able to successfully call my HTTPS WCF service in IE 11.
为我的站点绑定选择此证书后,我能够在 IE 11 中成功调用我的 HTTPS WCF 服务。
回答by moyu wang
I have the same issue too. at first i use make a get request before post. it solve the issue. but when i deep in, i find it's the in the internet option -》 Advanced options
我也有同样的问题。起初我使用在发布前发出一个获取请求。它解决了这个问题。但是当我深入时,我发现它是在互联网选项-》高级选项
- cancel check for server certificate revocation*
- cancel check for publisher certificate revocation*
- click ok
- restart your browser
- 取消对服务器证书吊销的检查*
- 取消对发布者证书吊销的检查*
- 单击确定
- 重新启动浏览器
i resolved the issue
我解决了这个问题