当Ajax请求完成之前location.href被改变,会发生什么? [英] What will happen when location.href is changed before ajax request completes?

查看:288
本文介绍了当Ajax请求完成之前location.href被改变,会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 在用户点击一些链接,执行一些Ajax请求 - 。可以说,这一请求需要20秒
  2. 请求之前完成用户点击奥德,它把整个页面的链接(不阿贾克斯)到另一个页面。

将Ajax请求发生什么情况?这将是永远完成服务器端,但不会回应任何地方来?或者,也许服务器端AJAX请求将immidiately封杀?

What will happen with ajax request? It will be always completed on server side but the response wont come anywhere? Or maybe ajax request on server side will be immidiately "killed?

我问,因为我有一些脚本,需要一些时间来运行,但用户没有现在的结果 - 它只是射后不理 - 也许还有在阿贾克斯甚至一些选项,迫使它不发送任何回应?

I ask because I have some script which takes some time to run but user doesn't have to now the result - it's just fire and forget - maybe there is even some option in ajax to force it not to send any response?

推荐答案

浏览器应该杀了AJAX请求,关闭连接到服务器;然而,这并不意味着你的服务器上的处理是必然打死也: ignore_user_abort()

The browser should kill the AJAX request, closing the connection to the server; however, this does not mean that your processing on the server is necessarily killed too: ignore_user_abort()

这篇关于当Ajax请求完成之前location.href被改变,会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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