My code utilizes an XMLHttpRequest to log in to a remote server by sending login parameters (username and password) as JSON. Here is my code snippet:
var json_data = JSON.stringify({
"method": "login",
"user_login": user,
"password": password
});
var post_url = "server_url";
var crossRequest = new XMLHttpRequest();
crossRequest.open('POST', post_url, true); //Async
crossRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
crossRequest.withCredentials = true;
crossRequest.onreadystatechange = function () {
if (crossRequest.readyState == 4) {
alert("Logged in!");
}
}
crossRequest.onabort = function () {
alert("ERROR: Aborted.");
}
crossRequest.onerror = function () {
//alert("Error occurred, status: " + crossRequest.status);
}
crossRequest.onload = function () {
if (crossRequest.status == 200)
{
alert("Logged in!");
}
else
{
alert("An error occurred, status: " + crossRequest.status);
}
}
crossRequest.send(json_data);
While this code works in Chrome, it consistently aborts in IE 11 before sending anything:
What could be causing this issue in IE 11 and what steps can be taken to resolve it?