Saturday, 15 March 2014

How to remove a global ajax event handler in jQuery -


This may sound like a very sophisticated question (I really like newbie in JQuery), but my problem is: / P>

Each time a special button is clicked on my website, I have to attach a function that registers a global AJAX event handler (.jaxSend, being exact) and check the options for the AJAX request Does.

However, since the button can be clicked multiple times, I need to delete the handler in some way so that the next button click does not re-engage a new event handler, resulting in event handlers Will be stacking.

If you are surprised, then I can not attach a callback to a specific agay request because I include the code through the Google Tag Manager custom HTML tag (if you know what I'm saying )

ajaxSend function only .on ('ajaxSend', ...) is a cover

so you should be able to use the $ (document) .off ('ajax send'). ) to remove all existing handlers.


No comments:

Post a Comment