为什么在Chrome中的onunload和onbeforeunload中,我的XMLHTTPRequest被取消了? [英] Why in Chrome in onunload and onbeforeunload, is my XMLHTTPRequest being cancelled?

查看:145
本文介绍了为什么在Chrome中的onunload和onbeforeunload中,我的XMLHTTPRequest被取消了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome版本30.0.1599.101 m.

Chrome Version 30.0.1599.101 m.

我看到还有另一条与此类似的帖子,但是没有答案.一个答案"是关于onbeforeunload工作的,但是没有.

I see there's another similar post about this but it's not answered. The one "answer" talks about onbeforeunload working, but it does not.

其他类似的帖子,但是beforeunload和unload仍然不允许ajax请求. 帖子2 帖子3 第4条 帖子5

Other similar posts but beforeunload and unload is still won't allow an ajax request. post 2 post 3 post 4 post 5

在关闭浏览器/刷新页面之前提交未保存的数据的最佳方法是什么?

What's the best way to do something like commit unsaved data before the browser is closed/page refreshed?

推荐答案

您正在浏览.浏览器将取消所有请求,因为没人"对此呼叫的应答感兴趣.

You are navigating away. A browser will cancel all requests, because "no one" is interested in the answer of this calls.

JavaScript上下文将被破坏,因此不会向onload处理程序通知服务器响应.

The JavaScript context will be destroyed, so no onload handler will be informed about the sever response.

使用本地存储并保存您的值.不要试图安全返回服务器.

Use the local storage and save your values. Don't try to safe back to the server.

http://www.html5rocks.com/en/features/storage

http://caniuse.com/#feat=namevalue-storage

这篇关于为什么在Chrome中的onunload和onbeforeunload中,我的XMLHTTPRequest被取消了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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