page redirect , before ajax call success

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:14:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!