Ajax request with JQuery on page unload

I believe you need to make the request synchronous instead (it’s asynchronous by default) using the async : false parameter.

Synchronous requests lock up the browser until they complete. If the request is asynchronous, the page just keeps on unloading. It’s quick enough that the request never even has time to fire off.

Leave a Comment