只读
XMLHttpRequest.statusText
特性返回
DOMString
containing the response's status message as returned by the HTTP server. Unlike
XMLHTTPRequest.status
which indicates a numerical status code, this property contains the
text
of the response status, such as "OK" or "Not Found". If the request's
readyState
是在
UNSENT
or
OPENED
state, the value of
statusText
will be an empty string.
If the server response doesn't explicitly specify a status text,
statusText
will assume the default value "OK".
var xhr = new XMLHttpRequest();
console.log('0 UNSENT', xhr.statusText);
xhr.open('GET', '/server', true);
console.log('1 OPENED', xhr.statusText);
xhr.onprogress = function () {
console.log('3 LOADING', xhr.statusText);
};
xhr.onload = function () {
console.log('4 DONE', xhr.statusText);
};
xhr.send(null);
/**
* Outputs the following:
*
* 0 UNSENT
* 1 OPENED
* 3 LOADING OK
* 4 DONE OK
*/
| 规范 | 状态 | 注释 |
|---|---|---|
| XMLHttpRequest | 实时标准 | WHATWG (Web 超文本应用程序技术工作组) 实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
statusText
|
Chrome 1 | Edge 12 | Firefox 1 |
IE
7
|
Opera Yes | Safari 1.2 | WebView Android Yes | Chrome Android 18 | Firefox Android 4 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 1.0 |
完整支持
见实现注意事项。
XMLHttpRequest