当窗口关闭或刷新太快时,ajax 调用如何终止(例如 stackoverflow 投票调用)?

发布于 2024-12-27 11:15:08 字数 324 浏览 0 评论 0原文

正如我在此元问题中所问:https://meta. stackexchange.com/questions/119259/voting-is-lost-due-to-ajax-call-latency

我想知道这个问题,它是如何发生的?

是因为浏览器发送了一条通知,显示我放弃了还是
是不是因为用户动作太快,浏览器甚至无法发送xhr请求?

As I asked in this meta question: https://meta.stackexchange.com/questions/119259/voting-is-lost-due-to-ajax-call-latency

I wonder about issue, how it occurs?

Is it because browser sends a notification that it says I gave upor
is it because it is really fast action by user that browser even could not send the xhr request?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玉环 2025-01-03 11:15:08

我猜想请求已发送,但浏览器会在页面卸载时取消 XHR 待处理请求。

XHR 请求可以通过 .abort() 方法手动取消,因此如果挂起的请求被中止,我不会感到惊讶。

I'd guess that the request is sent, but that browsers cancel XHR pending requests when a page is unloaded.

XHR requests can be canceled manually via the .abort() method, so it wouldn't surprise me if pending requests are aborted.

秋意浓 2025-01-03 11:15:08

我猜这是因为浏览器无法发起xhr请求。一旦 xhr 请求启动,无论您是否在同一页面(或左侧)都无关紧要。当您单击投票按钮时,在启动 xhr 之前可能会进行一些耗时的计算,如果您的下一步操作(移至下一页或类似的操作)快得多(这些计算无法完成),您的请求 xhr 请求可能不会已发起。

I guess it is because browser was not able to initiate xhr request. Once xhr request get initiated, it doesn't matter whether you are on same page (or) left. There may be sometime consuming calculations before initiating xhr while you click on voting button, if your next action (move to next page or something like that) is that much quicker (where these calculations couldn't complete), your request xhr request might not have initiated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文