How can I debug a request failing with net::ERR_FAILED

Viewed 347

I have a form I'm submitting by AJAX which was working when it first went up about a month ago and has stopped working since, failing with net::ERR_FAILED.

var xhttp = new XMLHttpRequest();
xhttp.open("POST", MAILER_URL, true);
xhttp.setRequestHeader("Content-type", "application/json; charset=utf-8");
xhttp.onload = function (e) {
  if (xhttp.readyState === 4) {
    if (xhttp.status === 200) {
      console.log(xhttp.responseText);
    } else {
      console.error(xhttp.statusText);
    }
  }
};
xhttp.onerror = function (e) {
  console.error(xhttp.statusText);
};
xhttp.send(JSON.stringify(data));

The onerror handler is called but logs a blank line to the console, and the next line in console is the net::ERR_FAILED message.

These requests aren't hitting the server at MAILER_URL. From devtools I've taken a copy of the request as a cURL command and run that, and confirmed the request is successful.

How can I debug the cause of the net::ERR_FAILED message on submission from the browser?

0 Answers
Related