I’ve ran into a bit of a problem trying to run synchronous AJAX call using the event $(window).unload.
According to the documentation though:
As of jQuery 1.8, the use of async: false is deprecated.
I’m trying to send the user’s data (a name, an age and a large string of numbers) to a php file all in one go just before they exit the page.
Is this possible?
Thanks.
Look at these:
Can the unload Event be Used to Reliably fire ajax Request?
Why can't I use jQuery to fire an AJAX request from an unload event handler?
Running a PHP through Ajax on Unload
Conclusion:
It’s better not to have async request.
And you must set ignore_user_abort() in your php so it doesn’t terminate when connection drops!