From 4873c5f1122ac800cf3c916a52df07e05ddc9dcf Mon Sep 17 00:00:00 2001 From: MDN Date: Fri, 11 Feb 2022 00:58:37 +0000 Subject: [CRON] sync translated content --- files/zh-cn/_redirects.txt | 7 ++ files/zh-cn/_wikihistory.json | 92 ++++++++-------- .../web/api/xmlhttprequest/abort_event/index.html | 57 ++++++++++ .../web/api/xmlhttprequest/error_event/index.html | 61 +++++++++++ .../web/api/xmlhttprequest/load_event/index.html | 55 ++++++++++ .../api/xmlhttprequest/loadstart_event/index.html | 55 ++++++++++ .../api/xmlhttprequest/progress_event/index.html | 65 +++++++++++ .../web/api/animation/cancel_event/index.html | 112 +++++++++++++++++++ files/zh-cn/web/api/animation/oncancel/index.html | 111 ------------------- .../xmlhttprequest/onreadystatechange/index.html | 120 -------------------- .../readystatechange_event/index.html | 121 +++++++++++++++++++++ .../xmlhttprequesteventtarget/onabort/index.html | 56 ---------- .../xmlhttprequesteventtarget/onerror/index.html | 60 ---------- .../xmlhttprequesteventtarget/onload/index.html | 54 --------- .../onloadstart/index.html | 54 --------- .../onprogress/index.html | 64 ----------- 16 files changed, 579 insertions(+), 565 deletions(-) create mode 100644 files/zh-cn/conflicting/web/api/xmlhttprequest/abort_event/index.html create mode 100644 files/zh-cn/conflicting/web/api/xmlhttprequest/error_event/index.html create mode 100644 files/zh-cn/conflicting/web/api/xmlhttprequest/load_event/index.html create mode 100644 files/zh-cn/conflicting/web/api/xmlhttprequest/loadstart_event/index.html create mode 100644 files/zh-cn/conflicting/web/api/xmlhttprequest/progress_event/index.html create mode 100644 files/zh-cn/web/api/animation/cancel_event/index.html delete mode 100644 files/zh-cn/web/api/animation/oncancel/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequest/onreadystatechange/index.html create mode 100644 files/zh-cn/web/api/xmlhttprequest/readystatechange_event/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html delete mode 100644 files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html (limited to 'files/zh-cn') diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index 8ef2f40181..3fa6160c00 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1217,6 +1217,7 @@ /zh-CN/docs/Web/API/APIWwindow.sidebar /zh-CN/docs/Web/API/Window/sidebar /zh-CN/docs/Web/API/AbortSignal/onabort /zh-CN/docs/Web/API/AbortSignal/abort_event /zh-CN/docs/Web/API/AmbientLightSensor/reading /zh-CN/docs/Web/API/AmbientLightSensor/illuminance +/zh-CN/docs/Web/API/Animation/oncancel /zh-CN/docs/Web/API/Animation/cancel_event /zh-CN/docs/Web/API/ArrayBuffer /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer /zh-CN/docs/Web/API/AudioContext/createAnalyser /zh-CN/docs/Web/API/BaseAudioContext/createAnalyser /zh-CN/docs/Web/API/AudioContext/createBiquadFilter /zh-CN/docs/Web/API/BaseAudioContext/createBiquadFilter @@ -1616,6 +1617,12 @@ /zh-CN/docs/Web/API/WindowTimers/clearTimeout /zh-CN/docs/Web/API/clearTimeout /zh-CN/docs/Web/API/XMLDocument.load /zh-CN/docs/Web/API/XMLDocument/load /zh-CN/docs/Web/API/XMLHttpRequest/FormData /zh-CN/docs/Web/API/FormData +/zh-CN/docs/Web/API/XMLHttpRequest/onreadystatechange /zh-CN/docs/Web/API/XMLHttpRequest/readystatechange_event +/zh-CN/docs/Web/API/XMLHttpRequestEventTarget/onabort /zh-CN/docs/conflicting/Web/API/XMLHttpRequest/abort_event +/zh-CN/docs/Web/API/XMLHttpRequestEventTarget/onerror /zh-CN/docs/conflicting/Web/API/XMLHttpRequest/error_event +/zh-CN/docs/Web/API/XMLHttpRequestEventTarget/onload /zh-CN/docs/conflicting/Web/API/XMLHttpRequest/load_event +/zh-CN/docs/Web/API/XMLHttpRequestEventTarget/onloadstart /zh-CN/docs/conflicting/Web/API/XMLHttpRequest/loadstart_event +/zh-CN/docs/Web/API/XMLHttpRequestEventTarget/onprogress /zh-CN/docs/conflicting/Web/API/XMLHttpRequest/progress_event /zh-CN/docs/Web/API/console.dir /zh-CN/docs/Web/API/Console/dir /zh-CN/docs/Web/API/console.group /zh-CN/docs/Web/API/Console/group /zh-CN/docs/Web/API/console.groupCollapsed /zh-CN/docs/Web/API/Console/groupCollapsed diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index 0faeae8e06..6cbfab7e35 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -7500,6 +7500,12 @@ "WhiteMind" ] }, + "Web/API/Animation/cancel_event": { + "modified": "2019-03-23T22:16:25.770Z", + "contributors": [ + "micblo" + ] + }, "Web/API/Animation/currentTime": { "modified": "2019-03-23T22:25:13.728Z", "contributors": [ @@ -7531,12 +7537,6 @@ "jiangbai333" ] }, - "Web/API/Animation/oncancel": { - "modified": "2019-03-23T22:16:25.770Z", - "contributors": [ - "micblo" - ] - }, "Web/API/Animation/play": { "modified": "2020-10-15T22:30:09.446Z", "contributors": [ @@ -24123,15 +24123,6 @@ "tangzhe7" ] }, - "Web/API/XMLHttpRequest/onreadystatechange": { - "modified": "2019-09-24T22:57:24.203Z", - "contributors": [ - "Ende93", - "Koopos", - "Cmen", - "holynewbie" - ] - }, "Web/API/XMLHttpRequest/open": { "modified": "2020-10-16T05:36:39.774Z", "contributors": [ @@ -24167,6 +24158,15 @@ "holynewbie" ] }, + "Web/API/XMLHttpRequest/readystatechange_event": { + "modified": "2019-09-24T22:57:24.203Z", + "contributors": [ + "Ende93", + "Koopos", + "Cmen", + "holynewbie" + ] + }, "Web/API/XMLHttpRequest/response": { "modified": "2020-10-15T21:52:12.557Z", "contributors": [ @@ -24291,37 +24291,6 @@ "rubyisapm" ] }, - "Web/API/XMLHttpRequestEventTarget/onabort": { - "modified": "2020-10-15T22:25:54.233Z", - "contributors": [ - "liushuyu" - ] - }, - "Web/API/XMLHttpRequestEventTarget/onerror": { - "modified": "2020-10-15T22:08:29.854Z", - "contributors": [ - "weiqinl" - ] - }, - "Web/API/XMLHttpRequestEventTarget/onload": { - "modified": "2020-10-15T22:03:25.613Z", - "contributors": [ - "evestorm" - ] - }, - "Web/API/XMLHttpRequestEventTarget/onloadstart": { - "modified": "2020-10-15T22:09:01.294Z", - "contributors": [ - "luxin88" - ] - }, - "Web/API/XMLHttpRequestEventTarget/onprogress": { - "modified": "2020-10-15T21:53:38.407Z", - "contributors": [ - "liushuyu", - "holynewbie" - ] - }, "Web/API/XMLSerializer": { "modified": "2020-10-15T21:14:45.671Z", "contributors": [ @@ -47327,6 +47296,37 @@ "AlexChao" ] }, + "conflicting/Web/API/XMLHttpRequest/abort_event": { + "modified": "2020-10-15T22:25:54.233Z", + "contributors": [ + "liushuyu" + ] + }, + "conflicting/Web/API/XMLHttpRequest/error_event": { + "modified": "2020-10-15T22:08:29.854Z", + "contributors": [ + "weiqinl" + ] + }, + "conflicting/Web/API/XMLHttpRequest/load_event": { + "modified": "2020-10-15T22:03:25.613Z", + "contributors": [ + "evestorm" + ] + }, + "conflicting/Web/API/XMLHttpRequest/loadstart_event": { + "modified": "2020-10-15T22:09:01.294Z", + "contributors": [ + "luxin88" + ] + }, + "conflicting/Web/API/XMLHttpRequest/progress_event": { + "modified": "2020-10-15T21:53:38.407Z", + "contributors": [ + "liushuyu", + "holynewbie" + ] + }, "conflicting/Web/API/caches": { "modified": "2020-10-28T03:25:10.149Z", "contributors": [ diff --git a/files/zh-cn/conflicting/web/api/xmlhttprequest/abort_event/index.html b/files/zh-cn/conflicting/web/api/xmlhttprequest/abort_event/index.html new file mode 100644 index 0000000000..289050d88b --- /dev/null +++ b/files/zh-cn/conflicting/web/api/xmlhttprequest/abort_event/index.html @@ -0,0 +1,57 @@ +--- +title: XMLHttpRequestEventTarget.onabort +slug: conflicting/Web/API/XMLHttpRequest/abort_event +translation_of: Web/API/XMLHttpRequestEventTarget/onabort +original_slug: 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/conflicting/web/api/xmlhttprequest/error_event/index.html b/files/zh-cn/conflicting/web/api/xmlhttprequest/error_event/index.html new file mode 100644 index 0000000000..2de18d0333 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/xmlhttprequest/error_event/index.html @@ -0,0 +1,61 @@ +--- +title: XMLHttpRequestEventTarget.onerror +slug: conflicting/Web/API/XMLHttpRequest/error_event +tags: + - API + - Event Handler + - XMLHttpRequestEventTarget +translation_of: Web/API/XMLHttpRequestEventTarget/onerror +original_slug: Web/API/XMLHttpRequestEventTarget/onerror +--- +
{{APIRef("XMLHttpRequest")}}
+ +

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

+ +

请注意只有在网络层级出现错误时才会调用此函数。如果错误只出现在应用层(比如发送一个HTTP的错误码),这个方法将不会被调用。

+ +

语法

+ +
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/conflicting/web/api/xmlhttprequest/load_event/index.html b/files/zh-cn/conflicting/web/api/xmlhttprequest/load_event/index.html new file mode 100644 index 0000000000..f4f1214644 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/xmlhttprequest/load_event/index.html @@ -0,0 +1,55 @@ +--- +title: XMLHttpRequestEventTarget.onload +slug: conflicting/Web/API/XMLHttpRequest/load_event +translation_of: Web/API/XMLHttpRequestEventTarget/onload +original_slug: 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/conflicting/web/api/xmlhttprequest/loadstart_event/index.html b/files/zh-cn/conflicting/web/api/xmlhttprequest/loadstart_event/index.html new file mode 100644 index 0000000000..924d3f94d9 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/xmlhttprequest/loadstart_event/index.html @@ -0,0 +1,55 @@ +--- +title: XMLHttpRequestEventTarget.onloadstart +slug: conflicting/Web/API/XMLHttpRequest/loadstart_event +translation_of: Web/API/XMLHttpRequestEventTarget/onloadstart +original_slug: 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/conflicting/web/api/xmlhttprequest/progress_event/index.html b/files/zh-cn/conflicting/web/api/xmlhttprequest/progress_event/index.html new file mode 100644 index 0000000000..3640fb9cd9 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/xmlhttprequest/progress_event/index.html @@ -0,0 +1,65 @@ +--- +title: XMLHttpRequestEventTarget.onprogress +slug: conflicting/Web/API/XMLHttpRequest/progress_event +translation_of: Web/API/XMLHttpRequestEventTarget/onprogress +original_slug: 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")}}

diff --git a/files/zh-cn/web/api/animation/cancel_event/index.html b/files/zh-cn/web/api/animation/cancel_event/index.html new file mode 100644 index 0000000000..339ac7e40f --- /dev/null +++ b/files/zh-cn/web/api/animation/cancel_event/index.html @@ -0,0 +1,112 @@ +--- +title: Animation.oncancel +slug: Web/API/Animation/cancel_event +tags: + - API + - Animation +translation_of: Web/API/Animation/oncancel +original_slug: Web/API/Animation/oncancel +--- +

{{ SeeCompatTable() }}{{ APIRef("Web Animations") }}

+ +

Web Animations API 的 {{domxref("Animation")}} 接口的 oncancel 属性是 {{event("cancel")}} 事件的事件处理程序。

+ +

当动作从其他状态进入 "idle" 播放状态,例如当动画在结束播放后从元素中移除时,cancel 事件可以 {{domxref("Animation.cancel()")}} 被手动触发。 

+ +
+

在新的动画中,创建一个新的初始的空闲动画不会触发 {{event("cancel")}} 事件。

+
+ +

语法

+ +
var cancelHandler = Animation.oncancel;
+
+Animation.oncancel = cancelHandler;
+ +

+ +

当动画被取消时,这个函数将会被执行。默认是 null 。

+ +

例子

+ +

如果动画被取消,将会从元素中移除它。

+ +
animation.oncancel = animation.effect.target.remove();
+
+ +

标准

+ + + + + + + + + + + + + + +
标准状态备注
{{SpecName('Web Animations', '#dom-animation-oncancel', 'Animation.oncancel' )}}{{Spec2('Web Animations')}}编辑草案中。
+ +

浏览器兼容性

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
功能ChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
基础支持{{CompatChrome(39.0)}}{{CompatGeckoDesktop(48)}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
功能AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
基础支持{{CompatVersionUnknown}}{{CompatGeckoMobile(48)}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
+ +

[1] Web Animations API 默认在 Firefox Developer Edition 和 Nightly builds 被启用。你可以在设置属性 dom.animations-api.core.enabled 为 true 时在 Beta 和 发行版 开启这个功能,你可以设置为 false 来禁用这个功能。

+ +

参见

+ + diff --git a/files/zh-cn/web/api/animation/oncancel/index.html b/files/zh-cn/web/api/animation/oncancel/index.html deleted file mode 100644 index 00e9b0fc98..0000000000 --- a/files/zh-cn/web/api/animation/oncancel/index.html +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: Animation.oncancel -slug: Web/API/Animation/oncancel -tags: - - API - - Animation -translation_of: Web/API/Animation/oncancel ---- -

{{ SeeCompatTable() }}{{ APIRef("Web Animations") }}

- -

Web Animations API 的 {{domxref("Animation")}} 接口的 oncancel 属性是 {{event("cancel")}} 事件的事件处理程序。

- -

当动作从其他状态进入 "idle" 播放状态,例如当动画在结束播放后从元素中移除时,cancel 事件可以 {{domxref("Animation.cancel()")}} 被手动触发。 

- -
-

在新的动画中,创建一个新的初始的空闲动画不会触发 {{event("cancel")}} 事件。

-
- -

语法

- -
var cancelHandler = Animation.oncancel;
-
-Animation.oncancel = cancelHandler;
- -

- -

当动画被取消时,这个函数将会被执行。默认是 null 。

- -

例子

- -

如果动画被取消,将会从元素中移除它。

- -
animation.oncancel = animation.effect.target.remove();
-
- -

标准

- - - - - - - - - - - - - - -
标准状态备注
{{SpecName('Web Animations', '#dom-animation-oncancel', 'Animation.oncancel' )}}{{Spec2('Web Animations')}}编辑草案中。
- -

浏览器兼容性

- -
{{CompatibilityTable}}
- -
- - - - - - - - - - - - - - - - - - - -
功能ChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
基础支持{{CompatChrome(39.0)}}{{CompatGeckoDesktop(48)}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -
- - - - - - - - - - - - - - - - - - - -
功能AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
基础支持{{CompatVersionUnknown}}{{CompatGeckoMobile(48)}}[1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
-
- -

[1] Web Animations API 默认在 Firefox Developer Edition 和 Nightly builds 被启用。你可以在设置属性 dom.animations-api.core.enabled 为 true 时在 Beta 和 发行版 开启这个功能,你可以设置为 false 来禁用这个功能。

- -

参见

- - diff --git a/files/zh-cn/web/api/xmlhttprequest/onreadystatechange/index.html b/files/zh-cn/web/api/xmlhttprequest/onreadystatechange/index.html deleted file mode 100644 index 76bd8c6ccf..0000000000 --- a/files/zh-cn/web/api/xmlhttprequest/onreadystatechange/index.html +++ /dev/null @@ -1,120 +0,0 @@ ---- -title: XMLHttpRequest.onreadystatechange -slug: Web/API/XMLHttpRequest/onreadystatechange -tags: - - XHR - - XMLHttpRequest - - 参考 - - 处理程序 - - 属性 - - 接口 -translation_of: Web/API/XMLHttpRequest/onreadystatechange ---- -
{{APIRef}}
- -

只要 readyState 属性发生变化,就会调用相应的处理函数这个回调函数会被用户线程所调用。XMLHttpRequest.onreadystatechange 会在 {{domxref("XMLHttpRequest")}} 的{{domxref("XMLHttpRequest.readyState", "readyState")}} 属性发生改变时触发 {{event("readystatechange")}} 事件的时候被调用。

- -
-

警告:这个方法不该用于同步的requests对象,并且不能在内部(C++)代码中使用.

-
- -

当一个 XMLHttpRequest 请求被 abort() 方法取消时,其对应的 readystatechange 事件不会被触发。

- -
-

UPDATE: 在下面的浏览器版本中会触发 (Firefox 51.0.1, Opera 43.0.2442.991, Safari 10.0.3 (12602.4.8), Chrome 54.0.2840.71, Edge, IE11). 例子在 here - 重新加载几次页面即可。

-
- -

语法

- -
XMLHttpRequest.onreadystatechange = callback;
- -

取值

- - - -

示例

- -
var xhr= new XMLHttpRequest(),
-    method = "GET",
-    url = "https://developer.mozilla.org/";
-
-xhr.open(method, url, true);
-xhr.onreadystatechange = function () {
-  if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
-    console.log(xhr.responseText)
-  }
-}
-xhr.send();
- -

规范

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

浏览器兼容性

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(1)}}{{CompatGeckoDesktop(1.0)}}{{CompatIe(7)}}[1]{{CompatVersionUnknown}}{{CompatSafari(1.2)}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}1.0{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
-
- -

[1] IE 5 和 6可以通过使用 ActiveXObject() 支持ajax。

diff --git a/files/zh-cn/web/api/xmlhttprequest/readystatechange_event/index.html b/files/zh-cn/web/api/xmlhttprequest/readystatechange_event/index.html new file mode 100644 index 0000000000..63cdfe5bf8 --- /dev/null +++ b/files/zh-cn/web/api/xmlhttprequest/readystatechange_event/index.html @@ -0,0 +1,121 @@ +--- +title: XMLHttpRequest.onreadystatechange +slug: Web/API/XMLHttpRequest/readystatechange_event +tags: + - XHR + - XMLHttpRequest + - 参考 + - 处理程序 + - 属性 + - 接口 +translation_of: Web/API/XMLHttpRequest/onreadystatechange +original_slug: Web/API/XMLHttpRequest/onreadystatechange +--- +
{{APIRef}}
+ +

只要 readyState 属性发生变化,就会调用相应的处理函数这个回调函数会被用户线程所调用。XMLHttpRequest.onreadystatechange 会在 {{domxref("XMLHttpRequest")}} 的{{domxref("XMLHttpRequest.readyState", "readyState")}} 属性发生改变时触发 {{event("readystatechange")}} 事件的时候被调用。

+ +
+

警告:这个方法不该用于同步的requests对象,并且不能在内部(C++)代码中使用.

+
+ +

当一个 XMLHttpRequest 请求被 abort() 方法取消时,其对应的 readystatechange 事件不会被触发。

+ +
+

UPDATE: 在下面的浏览器版本中会触发 (Firefox 51.0.1, Opera 43.0.2442.991, Safari 10.0.3 (12602.4.8), Chrome 54.0.2840.71, Edge, IE11). 例子在 here - 重新加载几次页面即可。

+
+ +

语法

+ +
XMLHttpRequest.onreadystatechange = callback;
+ +

取值

+ + + +

示例

+ +
var xhr= new XMLHttpRequest(),
+    method = "GET",
+    url = "https://developer.mozilla.org/";
+
+xhr.open(method, url, true);
+xhr.onreadystatechange = function () {
+  if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
+    console.log(xhr.responseText)
+  }
+}
+xhr.send();
+ +

规范

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

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(1)}}{{CompatGeckoDesktop(1.0)}}{{CompatIe(7)}}[1]{{CompatVersionUnknown}}{{CompatSafari(1.2)}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}1.0{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

[1] IE 5 和 6可以通过使用 ActiveXObject() 支持ajax。

diff --git a/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html b/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html deleted file mode 100644 index 38d305c1c2..0000000000 --- a/files/zh-cn/web/api/xmlhttprequesteventtarget/onabort/index.html +++ /dev/null @@ -1,56 +0,0 @@ ---- -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 deleted file mode 100644 index 3c604e5026..0000000000 --- a/files/zh-cn/web/api/xmlhttprequesteventtarget/onerror/index.html +++ /dev/null @@ -1,60 +0,0 @@ ---- -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")}} 事务由于错误而失败时调用的函数。

- -

请注意只有在网络层级出现错误时才会调用此函数。如果错误只出现在应用层(比如发送一个HTTP的错误码),这个方法将不会被调用。

- -

语法

- -
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 deleted file mode 100644 index 8e2c27016f..0000000000 --- a/files/zh-cn/web/api/xmlhttprequesteventtarget/onload/index.html +++ /dev/null @@ -1,54 +0,0 @@ ---- -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 deleted file mode 100644 index 1501afd132..0000000000 --- a/files/zh-cn/web/api/xmlhttprequesteventtarget/onloadstart/index.html +++ /dev/null @@ -1,54 +0,0 @@ ---- -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 deleted file mode 100644 index 40641b30a6..0000000000 --- a/files/zh-cn/web/api/xmlhttprequesteventtarget/onprogress/index.html +++ /dev/null @@ -1,64 +0,0 @@ ---- -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