I have a webpage that calls a rest endpoint using Ajax. I want to print out the http status code when my rest call errors. When the rest endpoint returns a 500, I can see 500 being printed. But when the call returns a 404, then the value 0 is printed. thrownError is blank.
I'm new to Javascript but can anyone tell me why 0 would be printed? It's only for 404s. I've tested 5xx and they are all fine.
$.ajax({
type: 'GET',
url: 'mysite.com',
crossDomain: true
success: function (data) {
console.log(data);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
},
});