页面重定向,在ajax调用成功之前 [英] page redirect , before ajax call success

查看:144
本文介绍了页面重定向,在ajax调用成功之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将jquery 1.7.2用于aspx页面的一些ajax调用. ajax调用webservice方法. 如果当ajax调用仍在进行但尚未成功时,如果用户按下刷新按钮或单击某个菜单以重定向到另一个页面,则Firebug控制台中显示的错误是没有意义的. 当用户尝试离开该页面时,我该如何杀死Ajax待处理的请求?

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?

推荐答案

您可以执行此操作 例如它是您的ajax调用函数

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()

这篇关于页面重定向,在ajax调用成功之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆