XMLHttpRequest.status - Web APIs 编辑
The read-only XMLHttpRequest.status
property returns the numerical HTTP status code of the XMLHttpRequest
's response.
Before the request completes, the value of status
is 0. Browsers also report a status of 0 in case of XMLHttpRequest
errors.
Example
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
*/
Specifications
Specification | Status | Comment |
---|---|---|
XMLHttpRequest | Living Standard | WHATWG living standard |
Browser compatibility
BCD tables only load in the browser
See also
- List of HTTP response codes
- HTTP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论