Jquery cancel request ajax

3

How can I cancelar uma solicitação do Ajax that has not yet received the answer using Jquery.

    
asked by anonymous 07.05.2015 / 14:41

1 answer

5

You can use the abort () method, for example:

var xhr = $.ajax({
    type: "POST",
    url: "pagina.php",
    success: function(msg){
      ...
    }
});

//aborta o request
xhr.abort();
    
07.05.2015 / 14:43