这篇翻译不完整。请帮忙从英语翻译这篇文章。
只读属性
XMLHttpRequest.statusText
返回了XMLHttpRequest
请求中由服务器返回的一个DOMString
类型的文本信息,这则信息中也包含了响应的数字状态码。不同于使用一个数字来指示的状态码XMLHTTPRequest.status
,这个属性包含了返回状态对应的文本信息,例如"OK"或是"Not Found"。如果请求的状态readyState
的值为"UNSENT"或者"OPENED",则这个属性的值将会是一个空字符串。如果服务器未明确指定一个状态文本信息,则
statusText
的值将会被自动赋值为"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); /** * 输出如下: * * 0 UNSENT * 1 OPENED * 3 LOADING OK * 4 DONE OK */
标准
标准 | 状态 | 备注 |
---|---|---|
XMLHttpRequest | Living Standard | WHATWG living standard |
浏览器兼容性
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Basic support | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 1 | IE
Full support
7
| Opera Full support Yes | Safari Full support 1.2 | WebView Android Full support Yes | Chrome Android Full support 18 | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.
参考内容
- List of HTTP response codes
- HTTP