I like the Ben Nadel procedure for handling this .
Essentially, you create a wrapper around the jQuery.ajax function, and you can create all kinds of things that happen for every ajax request in your application. One such thing is query tracking.
You will see that in his getJSON wrapper method, it accepts an optional "name" parameter for the request name. It can be anything, itβs just the key to determine where the request came from. In your case, this will be delivered every time the link is clicked. If the name parameter exists, it stores it in the tracking collection.
If another call arrives with the same request name, it is simply dropped. As soon as the original request returns, it clears the tracking flag for this request name.
This method is great for distributing many common functions to all ajax requests in your application. I created a multi-request handler that also allows you to determine the behavior of new requests - whether it will abort any existing ones or just drop it. This is useful if you want the last request to be processed, for example, to autocomplete.
womp
source share