只读 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 超文本应用程序技术工作组) 实时标准

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
statusText Chrome 1 Edge 12 Firefox 1 IE 7
7
Internet Explorer version 5 and 6 supported ajax calls using ActiveXObject()
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

图例

完整支持

完整支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: