Ajax Synchronous Request Failing in Chrome

Yes, in Chrome they just recently disallowed synchronous ajax during end-of-page events (like beforeunload and unload). You simply can't do that anymore in Chrome. Update: You can again, in v73 and v74, but it's slated (for now) to go away again in v75 v80 (Feb 2020). Follow the fun in this issue (thank you patmortech for finding that issue).

The modern alternative is to use sendBeacon, which lets the browser navigate away from the page while still giving you a chance to tell the server that's what's happening. This doesn't hold up page dismissal. But it's only POST, and since it doesn't hold up page dismissal, use cases relying on holding up page dismissal won't work with it.


Thanks both of you - Crowder and Charlietfl. Using Beacon solved the issue.

In case someone is looking for a solution, can follow this - http://qnimate.com/sending-data-to-server-on-page-unload/

Tags:

Ajax

Jquery