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



Question:

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


Solution:1

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');  


Solution:2

Set global option to false

$.ajaxSetup({ global: false });

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


Solution:3

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.


Solution:4

This worked for me.

$(document).ready(function () {     $(document).unbind('ajaxStart');     $(document).unbind('ajaxStop');   });  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »