I am using jQuery.ajax for my site where user can select multiple check box. And from the selected check box user will get the data.
For every select box it is doing ajax request and showing result.
But i am facing one problem where suppose user select 1st check box then again it is deselecting the 1st check box and again selecting 2nd check box. So for selecting first check box it is doing 1 st ajax call and when user deselect 1st select box it is doing 2nd ajax call then same for 2nd select box it is doing 3rd ajax call.
so simultaneously 3 ajax calls are active but i want a way to abort all previous ajax call those are still in pending or in progress and show result as per the last/recent ajax call.
Code i am using for Ajax call:
jQuery.ajax({url: '/xyz.php',
success: function(data) {
//do something
}
});