1. Веб-технологии для разработчиков
  2. Интерфейсы веб API
  3. XMLHttpRequest
  4. XMLHttpRequest.status

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

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

Совместимость с браузерами

Смотрите также

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /