I've got 3-4 ajax calls that will be made at some point. For one of those calls I'd like to trigger a function on the ajaxSend event which is global. This specific ajax call is not necesserily the first or last one in the sequence. It seems that if I attach the ajaxSend event to the $(document), my function will fire every other time that an ajaxSend event occurs. Here's what my code looks like:
//ajax call one $.ajax({ type: "POST", url: myUrl, data: myData }); //ajax call two <- let's say I'd like to fire ajaxSpecificFunc() here $.ajax({ type: "POST", url: myUrl, data: myData }); //ajax call three $.ajax({ type: "POST", url: myUrl, data: myData }); function ajaxSpecificFunc(){ $(document).on("ajaxSend", function() { //Some code that should only happen on ajaxSend but for only one ajax call }); } EDIT: I am aware of global:false property for ajax, but do not wish to use it, as this would mean I would have to modify every new ajax call in the future to have ajaxSpecificFunc() continue to fire for the one specific ajax call
ajaxSpecificFuncinto thealwaysorbeforeSendcallback for your specific AJAX call?