From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/xmlhttprequest/status/index.html | 80 +++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 files/ja/web/api/xmlhttprequest/status/index.html (limited to 'files/ja/web/api/xmlhttprequest/status') diff --git a/files/ja/web/api/xmlhttprequest/status/index.html b/files/ja/web/api/xmlhttprequest/status/index.html new file mode 100644 index 0000000000..afa2ef79c5 --- /dev/null +++ b/files/ja/web/api/xmlhttprequest/status/index.html @@ -0,0 +1,80 @@ +--- +title: XMLHttpRequest.status +slug: Web/API/XMLHttpRequest/status +tags: + - API + - XMLHttpRequest + - XMLHttpRequest の結果 + - status + - エラー + - プロパティ + - リファレンス +translation_of: Web/API/XMLHttpRequest/status +--- +
{{APIRef('XMLHttpRequest')}}
+ +

XMLHttpRequest.status プロパティは読み取り専用で、 XMLHttpRequest のレスポンスにおける数値の HTTP ステータスコードを返します。

+ + + +

リクエストが完了する前は、 status の値は 0 になります。 XMLHttpRequest がエラーになった場合も、ブラウザーはステータスとして 0 を返します。

+ +

+ +
var xhr = new XMLHttpRequest();
+console.log('UNSENT: ', xhr.status);
+
+xhr.open('GET', '/server');
+console.log('OPENED: ', xhr.status);
+
+xhr.onprogress = function () {
+  console.log('LOADING: ', xhr.status);
+};
+
+xhr.onload = function () {
+  console.log('DONE: ', xhr.status);
+};
+
+xhr.send();
+
+/**
+ * Outputs the following:
+ *
+ * UNSENT: 0
+ * OPENED: 0
+ * LOADING: 200
+ * DONE: 200
+ */
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('XMLHttpRequest', '#the-status-attribute')}}{{Spec2('XMLHttpRequest')}}WHATWG living standard
+ +

ブラウザーの互換性

+ + + +

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

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf