I've been working on this problem for a few days and reaching out on this forum since I feel like I've exhausted my options. I have a form hosted on a Drupal 7 website and need to submit the form values to an external url. The form uses a POST request over the HTTPS protocol via jQuery.AJAX
- Form works fine in Chrome, Firefox, and Safari
- 我在IE10+控制台中收到以下错误(使用IE10+时,Ajax调用总是进入错误函数):
SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3
I've tried the following:
-
正在添加ContentType:
// causes all of the jQuery callbacks to error out "application/json; charset=utf-8",
attempting an Ajax GET call before the actual POST (as suggested on another SO thread)
将
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);
}
});
});
});
Any guidance would be helpful! THANKS