为什么在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