Use jQuery and the Ajax library to make REQUESTS.
There is a way to save REQUESTS, follow the example ..
The user is moving and suddenly the connection goes down and the user does not notice it. And he continues doing what he did .. and suddenly he sends a request, obviously this request will not be sent but how to save this request when the internet back it to be sent and the user does not lose its content ..
This REQUEST has to be saved and be immune to the page refresh, so even if it closes the page, when it returns the pending requests will be sent.