Saturday, 28 April 2018

javascript - how can I cancel an Ajax request?




In phonegap how to cancel an ajax request in program, I would like to set cancel button for control the request when it's too slow




$.ajax({
type: "GET",
url: url,
success: function(m) {
alert( "success");
}
});

Answer



hi it's similar as Abort Ajax requests using jQuery,anyway This can help you




 var ab = $.ajax({  type: "GET",  url: url,  success: function(m)  {    alert( "success");  } });

//kill the request
ab.abort()

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...