2

Chrome Version 30.0.1599.101 m.

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.

Canceled request

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?

Community
  • 1
  • 1
Jerinaw
  • 5,260
  • 7
  • 41
  • 54

1 Answers1

1

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

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

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
  • Yea I was going to use local storage if I couldn't figure out a way to so it on unload. It would be nice if they let the request go to the server and ignore the response or something. – Jerinaw Oct 19 '13 at 20:12