The read-only 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
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
statusText
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE Full support 7 Full support 7 Notes' Internet Explorer version 5 and 6 supported ajax calls using |
Opera
Full support Yes |
Safari
Full support 1.2 |
WebView Android
Full support Yes |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- See implementation notes.'
- See implementation notes.
See also
- List of HTTP response codes
- HTTP
XMLHttpRequest.statusText by Mozilla Contributors is licensed under CC-BY-SA 2.5.