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");
}
});
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");
}
});
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()
Store the promise interface returned from ajax request in a global
variable
and abort
it on cancel click
var result = $.ajax({ type: "GET", url: url, success: function(m) { alert( "success"); } });
$('#cancel').click(function() {
result.abort();
});
var request= $.ajax({ type: "GET", url: url, success: function(m) { alert( "success"); } });
$('#cancel').click(function() {
request.abort();
});
this will abort the request from the client(browser) side but note : if the server has already received the request, it may continue processing the request (depending on the platform of the server) even though the browser is no longer listening for a response. There is no reliable way to make the web server stop processing a request that is in progress.