XMLHttpRequest.statusText - назва відповіді сервера.
XMLHttpRequest.statusText;
XMLHttpRequest - об'єкт XMLHttpRequest.
statusText властивість об'єкту XMLHttpRequest яка повертає рядок з назвою HTTP коду відповіді сервера.
По замовчуванню пустий рядок, якщо запит вдався то "OK", сторінку не знайдено "Not Found".
var xhr = new XMLHttpRequest();
xhr.open('GET', '', true);
xhr.onload = function(){
alert( this.statusText );
};
xhr.send();
var xhr = new XMLHttpRequest();
xhr.open('GET', '', false);
xhr.send();
alert( xhr.satusText );
var xhr = new XMLHttpRequest();
xhr.open('GET', '');
xhr.onreadystatechange=function(){
if(xhr.readyState==4)
{
if(xhr.statusText=="OK") alert("Завантажено: "+xhr.responseText);
else alert("не вдалося завантажити: "+xhr.statusText);
}
}
xhr.send();