The read-only XMLHttpRequest.status
property returns the numerical HTTP status code of the XMLHttpRequest
's response.
Before the request completes, the value of status
is 0. Browsers also report a status of 0 in case of XMLHttpRequest
errors.
var xhr = new XMLHttpRequest();
console.log('UNSENT: ', xhr.status);
xhr.open('GET', '/server');
console.log('OPENED: ', xhr.status);
xhr.onprogress = function () {
console.log('LOADING: ', xhr.status);
};
xhr.onload = function () {
console.log('DONE: ', xhr.status);
};
xhr.send();