LoginSignup
1
3

More than 5 years have passed since last update.

今更だけど・・・本当に今更なんだけどAjaxでerrorが出たときの対処法

Posted at

コンソールに出して確認するのじゃ。

$( function() {
  $( '#btn' ) .click(
  function() {
    $.ajax({
      url: '404.html',
      type:'POST',
      dataType: 'json',
      success: function(data) {
             alert("ok");
           },
      error: function(XMLHttpRequest, textStatus, errorThrown) {
             console.warn(XMLHttpRequest.responseText);
             console.warn(XMLHttpRequest.status);
             console.warn(textStatus);
             console.warn(errorThrown.message);
         },
      complete : function(data) {
             alert("finish");
         }
    });
  });
} );

こちらが解法としてベスト。ありがとうございます。
http://www.koikikukan.com/archives/2014/10/01-012345.php
書き方をアップデートしていかないとね。。。「対応してないブラウザがある」との却下は苦い夏の思い出。。。
http://www.koikikukan.com/archives/2012/10/02-005555.php
http://api.jquery.com/jQuery.ajax/

1
3
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
1
3