What is the accepted way to synchronize a webapp's data with a server when a user closes their browser window without first saving their work? I'm talking by either hitting the "X" or even by pressing F5 or something.
A little background:
The webapp in question has a main window, and then child windows which spawn from the main window, enabling sandboxed "work" to be done in the child windows. I don't have control over this aspect of the implementation.
The use case:
Each child window can have a fairly sizable amount of information entered before the user decides to click "OK" to persist the data on the server.
Things I've considered/tried:
The solution that I came up with is essentially a modified version of choice 4 from above.
I developed some logic which registers
onchange/onkeypress event handlers with nodes identified by a certain attribute (in this case
data-save-state="true") when the page loads.
The identified element's values are serialized and sent as a JSON object to the
Saver is responsible for queuing up sets of requests and sending them to the server as a group once no further changes have been detected for 1000 ms.
This was more overhead for me who had to develop the ability to do this, but now that it is there, it's pretty simple for other team members to integrate into their code.
As far as the potential for lost data, the only risk now is during that second of time before the save request is sent to the server. This solution seems very "Google Docs"-like in nature to me.