Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I unregister a handler set to jQuery.ajaxStart() function?

I tried doing $.ajaxStart(function(){}), but it does not replace it, but appended.

like image 930
kaneda Avatar asked Jul 29 '10 17:07

kaneda


4 Answers

If I understand, you want to remove the ajaxStart handler from the element.

If so, just use jQuery's unbind() since the handler is attached as an event.

$('selector').unbind('ajaxStart');
  • http://api.jquery.com/unbind/
  • http://api.jquery.com/ajaxStart/
like image 92
user113716 Avatar answered Nov 12 '22 09:11

user113716


Set global option to false

$.ajaxSetup({ global: false });

http://api.jquery.com/jQuery.ajaxSetup/

like image 2
kien ngo doan Avatar answered Nov 12 '22 09:11

kien ngo doan


Worth to note that since jQuery 1.9, the .ajaxStart() must be attached to the document, hence you can't attach it to an element, or unbind from an element other than document for that matter:

As of jQuery 1.9, all the handlers for the jQuery global Ajax events, including those added with the .ajaxStart() method, must be attached to document.

like image 2
Hamid Mosalla Avatar answered Nov 12 '22 09:11

Hamid Mosalla


This worked for me.

$(document).ready(function () {
   $(document).unbind('ajaxStart');
   $(document).unbind('ajaxStop');
 });
like image 1
Chris Pimenta Avatar answered Nov 12 '22 09:11

Chris Pimenta