For*_*Win 35 javascript php jquery internet-explorer json
我已经在这个问题上工作了几天,并在这个论坛上伸出手,因为我觉得我已经筋疲力尽了.我有一个在Drupal 7网站上托管的表单,需要将表单值提交给外部URL.该表单通过jQuery.AJAX使用HTTPS协议的POST请求
SCRIPT7002:XMLHttpRequest:网络错误0x2ef3,由于错误00002ef3无法完成操作
我尝试过以下方法:
添加contentType:
// causes all of the jQuery callbacks to error out
"application/json; charset=utf-8",
Run Code Online (Sandbox Code Playgroud)在实际POST之前尝试Ajax GET调用(如另一个SO线程所示)
添加header( 'Content-Type: application/json; charset=utf-8' );到请求中
组 crossDomain: true
添加了适当的CORS标头,并在下面粘贴表单代码:
$.ajax({
url: "[URL]", //the page to receive the form data
crossDomain: true,
type: "POST",
data: dataString, //posting to API
dataType: "json", //the data type the function should expect back from the server
success: function(data) {
if (data.response_status == "1") { //error for at least 1 field
//display error message
}
else {
//display thank you label next to input
}
} else {
//All form fields completed successfully! Redirect user to Thank you confirmation page
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert("there is an error!");
console.log("in error section");
console.log("jqXHR: " + jqXHR);
console.log("jqXHR.responseText: " + jqXHR.responseText);
console.log("textStatus: " + textStatus);
console.log("errorThrown: " + errorThrown);
data = $.parseJSON(jqXHR.responseText);
console.log("parseJSON data: " + data);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
我读过 SCRIPT7002:XMLHttpRequest:网络错误0x2ef3,由于错误00002ef3无法完成操作
任何指导都会有所帮助!谢谢
Eri*_*Law 12
OP提供了WireShark捕获,显示服务器使用HTTPS CertificateRequest消息请求证书,然后客户端立即FIN连接.
配置服务器不要求客户端证书后,问题就消失了.
使用Fiddler也会使问题消失,因为除非您将其配置为这样做,否则Fiddler永远不会从浏览器请求客户端证书.
我想知道是否只有受影响的客户端计算机具有匹配的证书和/或withCredentialsCORS XHR请求中的标志是否与此方案相关.
我在IE 8 + 9 + 10 + 11 Ajax调用中随机看到了这个错误.所有其他浏览器都没有问题.
它假设KeepAlive连接之间存在竞争条件.我正在使用Apache 2.4.7.
使用/etc/apache2/apache2.conf中的Apache 2默认设置,我能够重现有关每第十个Ajax调用的错误:
KeepAlive On
KeepAliveTimeout 5
Run Code Online (Sandbox Code Playgroud)
解决方案:设置
KeepAlive off
Run Code Online (Sandbox Code Playgroud)
要么
KeepAliveTimeout 1
Run Code Online (Sandbox Code Playgroud)
为我解决了这个问题.我建议任何遇到0x2ef3-Network错误的人在服务器上设置KeepAlive.如果错误消失,请再次打开它并使用KeepAliveTimeout的值进行测试.它们也可以设置为ms.
还有一种方法可以仅为Internet Explorer禁用KeepAlive.
小智 6
在我的环境中,我首先复制/粘贴了一些旧代码以供使用.所以" contentType"是"application/json".
当我发现IE11超过Windows 8时,只要我用鼠标点击提交按钮,就不会以很高的概率工作.但我也发现如果我按下键盘上的回车键,那么IE11就可以正常工作了.
请注意,我的inputelemnts和submit button嵌套在一个form元素中.
经过一段时间的努力,我来到了这个页面,但没有解决我的问题,因为我对后端技术一无所知.我只是一个知识有限的前端人.
然后我逐一尝试了很多修改.突然,jQuery官方API文档激发了我的灵感.我注释掉了" contentType"参数,以便" contentType"采用默认值,即"application/x-www-form-urlencoded; charset=UTF-8".然后问题解决了.
希望这会有所帮助.
我遇到过同样的问题.对我来说,这个问题似乎只发生在IE11上,通过Post调用,我一直在使用AngularJS提供商$ http来进行调用.这似乎是IE中的一个错误,它是一个证书问题.进行POST调用时,未正确加载安全证书信息.作为解决方法,在进行POST调用之前,请进行GET调用以正确加载证书.看一下下面的示例代码(它使用的是AngularJS)
$http({
method: "GET",
url: "/api/DummyGet"
}).success(
$http({
method: "POST",
url: "/api/PostCall",
data: data
})
);
Run Code Online (Sandbox Code Playgroud)
有关详细信息,您可以查看这两个链接 - http://jonnyreeves.co.uk/2013/making-xhr-request-to-https-domains-with-winjs/
- IE10/IE11 Abort Post Ajax Request After清除缓存并显示错误"网络错误0x2ef3"
| 归档时间: |
|
| 查看次数: |
63440 次 |
| 最近记录: |