From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/xmlhttprequesteventtarget/index.html | 64 +++++++++++++++++++++ .../xmlhttprequesteventtarget/onabort/index.html | 56 ++++++++++++++++++ .../xmlhttprequesteventtarget/onerror/index.html | 58 +++++++++++++++++++ .../xmlhttprequesteventtarget/onload/index.html | 54 ++++++++++++++++++ .../onloadstart/index.html | 54 ++++++++++++++++++ .../onprogress/index.html | 66 ++++++++++++++++++++++ 6 files changed, 352 insertions(+) create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html (limited to 'files/zh-cn/web/api/xmlhttprequesteventtarget') diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/index.html new file mode 100644 index 0000000000..dc6ddc6d37 --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/index.html @@ -0,0 +1,64 @@ +--- +title: XMLHttpRequestEventTarget +slug: Web/API/XMLHttpRequestEventTarget +tags: + - AJAX + - API + - XMLHttpRequest + - 参考 +translation_of: Web/API/XMLHttpRequestEventTarget +--- +

{{APIRef("XMLHttpRequest")}}

+ +

XMLHttpRequestEventTarget 是一个描述事件处理程序的接口,你可以在一个用于处理 {{ domxref("XMLHttpRequest") }} 事件的对象中使用到该事件处理程序。

+ +

{{InheritanceDiagram}}

+ +

属性

+ +
+
{{ domxref("XMLHttpRequestEventTarget.onabort") }}
+
当请求失败时调用该方法,接受 {{event('abort')}} 对象作为参数。
+
{{ domxref("XMLHttpRequestEventTarget.onerror") }}
+
当请求发生错误时调用该方法,接受 {{event('error')}} 对象作为参数。
+
{{ domxref("XMLHttpRequestEventTarget.onload") }}
+
当一个 HTTP 请求正确加载出内容后返回时调用,接受 {{event('load')}} 对象作为参数。
+
{{ domxref("XMLHttpRequestEventTarget.onloadstart") }}
+
当一个 HTTP 请求开始加载数据时调用,接受 {{event('loadstart')}} 对象作为参数。
+
{{ domxref("XMLHttpRequestEventTarget.onprogress") }}
+
间歇调用该方法用来获取请求过程中的信息,接受 {{event('progress')}} 对象作为参数。
+
{{ domxref("XMLHttpRequestEventTarget.ontimeout") }}
+
当超时时调用,接受 {{event("timeout")}} 对象作为参数;只有设置了 XMLHttpRequest 对象的 timeout 属性时,才可能发生超时事件。
+
{{ domxref("XMLHttpRequestEventTarget.onloadend") }}
+
当内容加载完成,不管失败与否,都会调用该方法,接受 {{event('loadend')}} 对象作为参数。
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('XMLHttpRequest')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget")}}

+ +

参见

+ + diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html new file mode 100644 index 0000000000..38d305c1c2 --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html @@ -0,0 +1,56 @@ +--- +title: XMLHttpRequestEventTarget.onabort +slug: Web/API/XMLHttpRequestEventTarget/onabort +translation_of: Web/API/XMLHttpRequestEventTarget/onabort +--- +
{{APIRef("XMLHttpRequest")}}
+ +

XMLHttpRequestEventTarget.onabort 会在 {{domxref("XMLHttpRequest")}} 交易操作被诸如 {{domxref("XMLHttpRequest.abort()")}} 函数中止时调用。

+ +

语法

+ +
XMLHttpRequest.onabort = callback;
+ +

+ + + +

示例

+ +
var xmlhttp = new XMLHttpRequest(),
+  method = 'GET',
+  url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(method, url, true);
+xmlhttp.onabort = function () {
+  console.log('** 请求被中止');
+};
+xmlhttp.send();
+//..
+xmlhttp.abort(); // 这将会调用我们上面定义的 onabort 回调函数
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('XMLHttpRequest', '#handler-xhr-onabort')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget.onabort")}}

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 +--- +
{{APIRef("XMLHttpRequest")}}
+ +

XMLHttpRequestEventTarget.onerror 是{{domxref("XMLHttpRequest")}} 事务由于错误而失败时调用的函数。

+ +

语法

+ +
XMLHttpRequest.onerror = callback;
+ +

Values

+ + + +

举例

+ +
var xmlhttp = new XMLHttpRequest(),
+  method = 'GET',
+  url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(method, url, true);
+xmlhttp.onerror = function () {
+  console.log("** An error occurred during the transaction");
+};
+xmlhttp.send();
+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest', '#handler-xhr-onerror')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget.onerror")}}

diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html new file mode 100644 index 0000000000..8e2c27016f --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html @@ -0,0 +1,54 @@ +--- +title: XMLHttpRequestEventTarget.onload +slug: Web/API/XMLHttpRequestEventTarget/onload +translation_of: Web/API/XMLHttpRequestEventTarget/onload +--- +
{{APIRef("XMLHttpRequest")}}
+ +

XMLHttpRequestEventTarget.onload 是 {{domxref("XMLHttpRequest")}} 请求成功完成时调用的函数。

+ +

语法

+ +
XMLHttpRequest.onload = callback;
+ +

+ + + +

示例

+ +
var xmlhttp = new XMLHttpRequest(),
+  method = 'GET',
+  url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(method, url, true);
+xmlhttp.onload = function () {
+  // 处理取回的数据(在 xmlhttp.response 中找到)
+};
+xmlhttp.send();
+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest', '#handler-xhr-onload')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget.onload")}}

diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html new file mode 100644 index 0000000000..1501afd132 --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html @@ -0,0 +1,54 @@ +--- +title: XMLHttpRequestEventTarget.onloadstart +slug: Web/API/XMLHttpRequestEventTarget/onloadstart +translation_of: Web/API/XMLHttpRequestEventTarget/onloadstart +--- +
{{APIRef("XMLHttpRequest")}}
+ +

XMLHttpRequestEventTarget.onloadstart 在{{domxref("XMLHttpRequest")}} 开始传送数据时被调用

+ +

语法

+ +
XMLHttpRequest.onloadstart = callback;
+ +

+ + + +

示例

+ +
var xmlhttp = new XMLHttpRequest(),
+  method = 'GET',
+  url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(method, url, true);
+xmlhttp.onloadstart = function () {
+  console.log("Download underway");
+};
+xmlhttp.send();
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态说明
{{SpecName('XMLHttpRequest', '#handler-xhr-onloadstart')}}{{Spec2('XMLHttpRequest')}}WHATWG 现存标准
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget.onloadstart")}}

diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html new file mode 100644 index 0000000000..ad2bced50b --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html @@ -0,0 +1,66 @@ +--- +title: XMLHttpRequestEventTarget.onprogress +slug: Web/API/XMLHttpRequestEventTarget/onprogress +translation_of: Web/API/XMLHttpRequestEventTarget/onprogress +--- +

{{APIRef("XMLHttpRequest")}}

+ +

XMLHttpRequestEventTarget.onprogress 是在 {{domxref("XMLHttpRequest")}} 完成之前周期性调用的函数。

+ +

语法

+ +
XMLHttpRequest.onprogress = callback;
+ +

+ + + +

事件

+ + + +
XMLHttpRequest.onprogress = function (event) {
+  event.loaded;
+  event.total;
+};
+ +

示例

+ +
var xmlhttp = new XMLHttpRequest(),
+  method = 'GET',
+  url = 'https://developer.mozilla.org/';
+
+xmlhttp.open(method, url, true);
+xmlhttp.onprogress = function () {
+  //do something
+};
+xmlhttp.send();
+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('XMLHttpRequest', '#handler-xhr-onload')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

浏览器兼容性

+ + + +

{{Compat("api.XMLHttpRequestEventTarget.onprogress")}}

-- cgit v1.2.3-54-g00ecf