问题
I'm using jquery 1.7.2 for some ajax call onloud of an aspx page. ajax calls webservice methods . if user push refresh button or click on some menu to redirect to another page when ajax calls still in progress and not success yet, an error shown in firebug console that not make sense. what can i do to kill ajax pending requests when user try to leave the page?
回答1:
you can do this for instance it your ajax calling function
var call = $.ajax({
type: "POST",
url: "mywebservice.aspx",
data: "some data you are passing ",
success: function(msg){
// do stuff on sucess
}
});
and the you can call this to kill the process.
call.abort()
来源:https://stackoverflow.com/questions/10630380/page-redirect-before-ajax-call-success