Tino
Tino

Reputation: 304

Why is my XMLHttpRequest being aborted?

I have an XMLHttpRequest that I'm sending to log in to a remote server. I'm taking the login parameters (username and password) and sending them as json. Here's my code:

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);

It works just fine in Chrome, but in IE 11 it always aborts, seemingly before sending anything:

IE 11 Dev Panel Network

IE 11 Dev Panel Error

What could be causing this, and how can I fix it?

Upvotes: 2

Views: 8238

Answers (2)

Raman Zhylich
Raman Zhylich

Reputation: 3697

• Press Alt, then go to Tools and turn off Enterprise mode if it’s not turned off yet.
• Go to Tools -> Internet Options -> Security -> Reset all zones to default level
• Go to Tools -> Internet Options -> Advanced -> Restore advanced settings
• Go to Tools -> Internet Options -> General -> Delete -> Temporary Internet Files and website files.

Upvotes: 0

Related Questions