Reputation: 2477
What can I expect if I initiate an XMLHttpRequest when the onClose event of the tab or browser window is fired? What happens if the XMLHttpRequest takes too long? Will the request be aborted or cut short as the window closes? Is there a guarantee that the request will be allowed to run it's natural course (and terminate with time out, 200, 303, 404 or 500)?
Will using jQuery make any difference?
I am unable simulate a slow connection to test this out on a browser.
Upvotes: 0
Views: 342
Reputation: 11042
You can never be guaranteed that any request will complete, and this case is no exception.
You might have better luck with either the onunload
or onbeforeunload
events, especially the latter.
Upvotes: 1