Consider I have 4 option like
On clicking of each option i am making an ajax request and pulling the appropriate details and displaying it. but the problem is for an instance i click on the display Name
option the ajax request is sent immediately i click on the display Age
option this triggers an ajax request and displays the data when the first request's response comes back it overwrites the data of the second request, So can i stop the previous ajax request(s). Thanks.
yes possible.
var ajaxCall=$.ajax({
-----
------
});
then.You can use the following code, If you want reject of the ajax response
ajaxCall.abort()
Use a variable to store a AJAX request:
var request = $.ajax({
type: 'POST',
url: 'someurl',
success: function(result){}
});
AND abort the request before you call again the same AJAX function:
request.abort();
You could use an array keeping track of all pending ajax requests and abort them if necessary.