この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!
The XMLHttpRequest.statusText property returns a 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
is in 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".
Example
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 */
Specifications
Specification | Status | Comment |
---|---|---|
XMLHttpRequest | Living Standard | WHATWG living standard |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1 | 1.0 (1.7 or earlier)[1] | 7[1] | (Yes) | 1.2 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | 1.0 | (Yes) | ? | ? | ? |
[1] Internet Explorer versions 5 and 6 lacked the XMLHttpRequest object, but provided a way to make AJAX requests using ActiveXObject
.
See also
- List of HTTP response codes