Hi have a page which has List data.
When I click on an element of the list, an Ajax function is called which populates some date in the right column.
Now wat’s working:-
i click on element -> i see the loading.gif a few seconds -> data gets loaded.
When i click on other element midway, the first function completes and only then the second request is taken.
What I want:-
when i click and the ajax is loading, I click again in between, the previous function should stop, and my new request should be taken.
You can stop AJAX requests (I’m guessing you don’t want to actually stop the AJAX response handler function (which should take the least time in a usual AJAX scenario), but want to stop the request: Look here:
Basically, store your request object somewhere (closure, global variable or wherever), and whenever you start a new request, check if an old one is still running, and if it is, call the
abort()method on the old request!