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 5 years have passed since last update.

jQueryでajaxSendが動かなくなった時の対応

2
Last updated at Posted at 2016-01-16

ある既存プロジェクトで、Ajaxしてる間にスピナーを出して完了したら消すみたいな処理をやっていました。
コード(CoffeeScript)はこんな感じ。

$('#spinner').
    bind('ajaxSend', ->
      // スピナー表示
    bind('ajaxComplete', ->
     // スピナー非表示

jQueryのバージョンを1.7.2 -> 1.11.1にしたらイベントを検知しなくなりました。
原因を調べてみると、ajaxSendのドキュメントに

jQuery1.8で、.ajaxSend()メソッドはdocumentのみにしか使用できなくなりました。

て書いてありました。
なので、

$(document).
    bind('ajaxSend', ->
      // スピナー表示
    bind('ajaxComplete', ->
     // スピナー非表示

こうしてあげると、しっかり検知してくれるようになりました。

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?