aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html')
-rw-r--r--files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html
new file mode 100644
index 0000000000..c6931f08ef
--- /dev/null
+++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html
@@ -0,0 +1,58 @@
+---
+title: XMLHttpRequestEventTarget.onerror
+slug: Web/API/XMLHttpRequestEventTarget/onerror
+tags:
+ - API
+ - Event Handler
+ - XMLHttpRequestEventTarget
+translation_of: Web/API/XMLHttpRequestEventTarget/onerror
+---
+<div>{{APIRef("XMLHttpRequest")}}</div>
+
+<p><strong><code>XMLHttpRequestEventTarget.onerror</code></strong> 是{{domxref("XMLHttpRequest")}} 事务由于错误而失败时调用的函数。</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><em>XMLHttpRequest</em>.onerror = <em>callback</em>;</pre>
+
+<h3 id="Values">Values</h3>
+
+<ul>
+ <li><code><em>callback</em></code> 是当请求失败时执行的函数。</li>
+</ul>
+
+<h2 id="Example" name="Example">举例</h2>
+
+<pre class="brush: js">var xmlhttp = new XMLHttpRequest(),
+ method = 'GET',
+ url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(<em>method</em>, <em>url</em>, true);
+xmlhttp.onerror = function () {
+ console.log("** An error occurred during the transaction");
+};
+xmlhttp.send();
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('XMLHttpRequest', '#handler-xhr-onerror')}}</td>
+ <td>{{Spec2('XMLHttpRequest')}}</td>
+ <td>WHATWG living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.XMLHttpRequestEventTarget.onerror")}}</p>