cancel previous ajax request

Solutions on MaxInterview for cancel previous ajax request by the best coders in the world

showing results for - "cancel previous ajax request"
Arsène
13 May 2018
1 var currentRequest = null;    
2
3currentRequest = jQuery.ajax({
4    type: 'POST',
5    data: 'value=' + text,
6    url: 'AJAX_URL',
7    beforeSend : function()    {           
8        if(currentRequest != null) {
9            currentRequest.abort();
10        }
11    },
12    success: function(data) {
13        // Success
14    },
15    error:function(e){
16      // Error
17    }
18});