I have a situation where on page unload I am firing a request to delete the draft of a user\'s work. This works fine until a user chooses to refresh the page, whereupon ins
In onbeforeunload or $.unload() set up your AJAX object with async = false. This will make sure the ajax call completes before the page is unloaded.
I know this question is a few months old, but I wanted to add this info in case it helps anyone searching for a similar issue with AJAX!