From c826e72a7115f4e5d2e0a3cd19ddd843e1dfb9eb Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Sun, 30 Jan 2022 00:29:45 +0900 Subject: 2021/09/15 時点の英語版に同期 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ja/web/api/xmlhttprequest/error_event/index.md | 139 +++++++++------------ 1 file changed, 62 insertions(+), 77 deletions(-) (limited to 'files/ja/web/api/xmlhttprequest') diff --git a/files/ja/web/api/xmlhttprequest/error_event/index.md b/files/ja/web/api/xmlhttprequest/error_event/index.md index 0563f46771..d1a6b33b86 100644 --- a/files/ja/web/api/xmlhttprequest/error_event/index.md +++ b/files/ja/web/api/xmlhttprequest/error_event/index.md @@ -4,57 +4,58 @@ slug: Web/API/XMLHttpRequest/error_event tags: - API - Error - - Event - - ProgressEvent - - Web - - XMLHttpRequest - イベント + - ProgressEvent - ウェブ + - XMLHttpRequest +browser-compat: api.XMLHttpRequest.error_event translation_of: Web/API/XMLHttpRequest/error_event --- -
{{APIRef}}
+{{APIRef}} -

error イベントは、リクエストでエラーが発生したときに発生します。

+`error` イベントは、リクエストでエラーが発生したときに発行されます。 - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
バブリングなし
キャンセル可能いいえ
インターフェイス{{domxref("ProgressEvent")}}
イベントハンドラープロパティ{{domxref("XMLHttpRequestEventTarget/onerror", "onerror")}}
バブリングなし
キャンセル不可
インターフェイス{{domxref("ProgressEvent")}}
イベントハンドラープロパティ + {{domxref("XMLHttpRequestEventTarget/onerror", "onerror")}} +
-

+## 例 -

ライブデモ

+### ライブデモ -

HTML

+#### HTML -
<div class="controls">
-    <input class="xhr success" type="button" name="xhr" value="Click to start XHR (success)" />
-    <input class="xhr error" type="button" name="xhr" value="Click to start XHR (error)" />
-    <input class="xhr abort" type="button" name="xhr" value="Click to start XHR (abort)" />
-</div>
-
-<textarea readonly class="event-log"></textarea>
+```html +
+ + + +
- +``` -

JS

+#### JS -
const xhrButtonSuccess = document.querySelector('.xhr.success');
+```js
+const xhrButtonSuccess = document.querySelector('.xhr.success');
 const xhrButtonError = document.querySelector('.xhr.error');
 const xhrButtonAbort = document.querySelector('.xhr.abort');
 const log = document.querySelector('.event-log');
@@ -99,48 +100,32 @@ function runXHR(url) {
     return xhr;
 }
 
-xhrButtonSuccess.addEventListener('click', () => {
-    runXHR('https://mdn.mozillademos.org/files/16553/DgsZYJNXcAIPwzy.jpg');
+xhrButtonSuccess.addEventListener('click', () => {
+    runXHR('dgszyjnxcaipwzy.jpg');
 });
 
-xhrButtonError.addEventListener('click', () => {
+xhrButtonError.addEventListener('click', () => {
     runXHR('https://somewhere.org/i-dont-exist');
 });
 
-xhrButtonAbort.addEventListener('click', () => {
-    runXHR('https://mdn.mozillademos.org/files/16553/DgsZYJNXcAIPwzy.jpg').abort();
-});
- -

結果

- -

{{ EmbedLiveSample('Live_example', '100%', '150px') }}

- -

仕様書

- - - - - - - - - - - - - - - - -
仕様書状態備考
{{SpecName('XMLHttpRequest', '#event-xhr-error')}}{{Spec2('XMLHttpRequest')}}
+xhrButtonAbort.addEventListener('click', () => { + runXHR('dgszyjnxcaipwzy.jpg').abort(); +}); +``` + +#### 結果 + +{{ EmbedLiveSample('Live_example', '100%', '150px') }} + +## 仕様書 + +{{Specifications}} -

ブラウザーの互換性

+## ブラウザーの互換性 -

{{Compat("api.XMLHttpRequest.error_event")}}

+{{Compat}} -

関連情報

+## 関連情報 - +- 関連イベント: {{domxref("XMLHttpRequest/loadstart_event", "loadstart")}}, {{domxref("XMLHttpRequest/load_event", "load")}}, {{domxref("XMLHttpRequest/progress_event", "progress")}}, {{domxref("XMLHttpRequest/loadend_event", "loadend")}}, {{domxref("XMLHttpRequest/abort_event", "abort")}} +- [進捗の監視](/ja/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#monitoring_progress) -- cgit v1.2.3-54-g00ecf