2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

jQuery.ajax : fail(jqXHR, textStatus, errorThrown)

Last updated at Posted at 2020-06-30

jQuery.ajax : fail

jQuery の $.ajax による非同期通信は、レガシーな開発対象では大変有用です。

エラーハンドリングの必要性を考慮し .fail に渡ってくる引数と、その内容を実装ベースで調べました:

.fail(function(jqXHR, textStatus, errorThrown) {
  // jqXHR
  //  .status: 500
  //  .statusText: "Internal Server Error"
  //  .responseJSON: {
  //    "StatusCode": 500,
  //    "Message": "Something went horribly, horribly wrong while servicing your request.",
  //    "Details": "Nancy.RequestExecutionException: Oh noes! ---> System.NullReferenceException: オブジェクト参照がオブジェクト インスタンスに設定されていません。\r\n   場所 ..."
  //  }
  //  .responseText: "{"StatusCode":500,"Message":"Something went horribly, horribly wrong while servicing your request.","Details":"Nancy.RequestExecutionException: Oh noes! ---> System.NullReferenceException: オブジェクト参照がオブジェクト インスタンスに設定されていません。\r\n   場所 ..."
  //  .getAllResponseHeaders(): "cache-control: no-store, no-cache, must-revalidate\r\nconnection: close\r\ncontent-type: application/json; charset=utf-8\r\ndate: Tue, 30 Jun 2020 05:02:13 GMT\r\nexpires: Thu, 19 Nov 1981 08:52:00 GMT\r\nlink: </add-addr.xml>; rel=\"application/xml\"\r\npragma: no-cache\r\nserver: Apache/2.4.41 (Win32) mod_fcgid/2.3.10-dev\r\ntransfer-encoding: chunked\r\nvary: Accept\r\nx-powered-by: PHP/7.4.2\r\n"
  // textStatus: "error"
  // errorThrown: "Internal Server Error"
});
  • jqXHR は略称とのことで (The jQuery XMLHttpRequest (jqXHR) object)
    XMLHttpRequest オブジェクトのスーパーセットとの説明があります (a superset of the browser's native XMLHttpRequest object.)
  • textStatuserrorThrown は、両方とも string でした。

参考:

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?