只读
XMLHttpRequest.status
property returns the numerical HTTP
status code
的
XMLHttpRequest
's response.
Before the request completes, the value of
status
is 0. Browsers also report a status of 0 in case of
XMLHttpRequest
错误。
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
*/
| 规范 | 状态 | 注释 |
|---|---|---|
| XMLHttpRequest | 实时标准 | WHATWG (Web 超文本应用程序技术工作组) 实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
status
|
Chrome 1 | Edge 12 | Firefox 1 |
IE
7
|
Opera 8 | Safari 1.2 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 |
完整支持
见实现注意事项。
XMLHttpRequest