This page was translated from English by the community. Learn more and join the MDN Web Docs community.
XMLHttpRequest.status
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since июль 2015 г..
Доступное только для чтения свойство XMLHttpRequest.status, возвращает числовой код состояния HTTP ответа XMLHttpRequest.
До завершения запроса значение status равно 0. Браузеры также сообщают о состоянии 0 в случае ошибок XMLHttpRequest.
Пример
js
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();
/**
* Outputs the following:
*
* UNSENT: 0
* OPENED: 0
* LOADING: 200
* DONE: 200
*/
Спецификации
| Specification |
|---|
| XMLHttpRequest> # the-status-attribute> |
Совместимость с браузерами
Enable JavaScript to view this browser compatibility table.
Смотрите также
- Список HTTP response codes
- HTTP