LoginSignup
2
12

More than 5 years have passed since last update.

jQueryのajaxデバッグ方法

Posted at

表題の通り、jQueryのajaxをデバッグするには、コールバックを登録すればいいらしい。
ついでにキャッシュも無効化しよう。

before.js
$.ajax({
    type: 'GET',
    url: '/api.php',
    dataType: 'json',
    data: {
        hoge: 'hage'
    },
    async: false
})
.done(function(response) {
    result = response;
})
.fail(function () {
    console.log('error');
});
after.js
$.ajax({
    type: 'GET',
    url: '/api.php',
    dataType: 'json',
    data: {
        hoge: 'hage'
    },
    async: false,
    cache: false,
    success: function(result){
      console.debug("result" + result);
    },
    error: function(jqxhr, status, exception) {
      console.debug('jqxhr', jqxhr);
      console.debug('status', status);
      console.debug('exception', exception);
    }
})
.done(function(response) {
    result = response;
})
.fail(function () {
    console.log('error');
});
2
12
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
12