Make an AJAX call when the user leaves a web page (using onbeforeunload)
Sometimes you need to send some data to the server before the user leaves your web application. A good example of this is saving data. Instead of giving the user a save button to save the changes he made, the application saves all data if the user navigates away from