Possible Duplicate:
Ajax request in progress jQuery
what I try to achieve is something like :
var calling = {};
if(!calling[resourceId]){
$.ajax(...);
calling[resourceId] = true;
}
Obviously, I want to avoid making two calls for the same resource at the same time. But I find it ugly to use a global variable across my scripts for this. I would like to know if you knew a nice way to handle this directly with jQuery ?
The best solution that I can think of is a monkey patch on jQuery.ajax to provide it with some "resourceId" parameter, and before any call the jQuery.ajax() function itself would check if a call is already being made with that "resourceId". I could not find such an option in the $.ajax documentation and I wonder why !?
Thank you.
UPDATE: I found exactly what I was looking for on in jQuery's Prefilters option, on the "Extending Ajax" documentation page. : http://api.jquery.com/extending-ajax/
Thanks for tips people :)