aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/xmlhttprequest/status/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/xmlhttprequest/status/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/xmlhttprequest/status/index.html')
-rw-r--r--files/zh-cn/web/api/xmlhttprequest/status/index.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/xmlhttprequest/status/index.html b/files/zh-cn/web/api/xmlhttprequest/status/index.html
new file mode 100644
index 0000000000..d248bf2090
--- /dev/null
+++ b/files/zh-cn/web/api/xmlhttprequest/status/index.html
@@ -0,0 +1,79 @@
+---
+title: XMLHttpRequest.status
+slug: Web/API/XMLHttpRequest/status
+tags:
+ - API
+ - Error
+ - Property
+ - Reference
+ - XMLHttpRequest
+ - XMLHttpRequest 状态
+ - result
+ - status
+translation_of: Web/API/XMLHttpRequest/status
+---
+<div>{{APIRef('XMLHttpRequest')}}</div>
+
+<div>只读属性 <code><strong>XMLHttpRequest.status</strong></code> 返回了<code>XMLHttpRequest</code> 响应中的数字状态码。<code>status</code> 的值是一个<code>无符号短整型</code>。在请求完成前,<code>status</code>的值为<code>0</code>。值得注意的是,如果 XMLHttpRequest 出错,浏览器返回的 status 也为0。</div>
+
+<div> </div>
+
+<div>status码是标准的<a href="/en-US/docs/Web/HTTP/Response_codes">HTTP status codes</a>。举个例子,<code>status</code> <code>200</code> 代表一个成功的请求。如果服务器响应中没有明确指定status码,<code>XMLHttpRequest.status</code> 将会默认为<code>200</code>。</div>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush: js">var xhr = new XMLHttpRequest();
+console.log('UNSENT', xhr.status);
+
+xhr.open('GET', '/server', true);
+console.log('OPENED', xhr.status);
+
+xhr.onprogress = function () {
+ console.log('LOADING', xhr.status);
+};
+
+xhr.onload = function () {
+ console.log('DONE', xhr.status);
+};
+
+xhr.send(null);
+
+/**
+ * 输出如下:
+ *
+ * UNSENT(未发送) 0
+ * OPENED(已打开) 0
+ * LOADING(载入中) 200
+ * DONE(完成) 200
+ */
+</pre>
+
+<h2 id="标准">标准</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">标准</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('XMLHttpRequest', '#the-status-attribute')}}</td>
+ <td>{{Spec2('XMLHttpRequest')}}</td>
+ <td>WHATWG living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">本页面中的兼容性列表生成自结构性的数据。如果你想帮助改进这些数据,请访问<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 然后提交 request。.</div>
+
+<p>{{Compat("api.XMLHttpRequest.status")}}</p>
+
+<h2 id="其他相关资料">其他相关资料</h2>
+
+<ul>
+ <li>HTTP响应代码(<a href="/en-US/docs/Web/HTTP/Response_codes">HTTP response codes</a>) 列表</li>
+ <li><a href="/en-US/docs/Web/HTTP">HTTP</a></li>
+</ul>