我已经在这个问题上研究了几天并在这个论坛上伸出援手,因为我觉得我已经用尽了我的选择。我有一个托管在 Drupal 7 网站上的表单,需要将表单值提交到外部 url。该表单通过 jQuery.AJAX 通过 HTTPS 协议使用 POST 请求
- 表单在 Chrome、Firefox 和 Safari 中运行良好
- 我在 IE10+ 控制台中收到以下错误(使用 IE10+ 时,ajax 调用总是进入错误函数):
SCRIPT7002:XMLHttpRequest:网络错误 0x2ef3,由于错误 00002ef3 无法完成操作
我尝试了以下方法:
添加内容类型:
// causes all of the jQuery callbacks to error out "application/json; charset=utf-8",
在实际 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);
}
});
});
});
我已阅读 SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3,由于错误 00002ef3 无法完成操作
任何指导都会有所帮助!谢谢