Ajax call during page unload event

Forums AJAXAjax call during page unload event
Staff asked 2 weeks ago

I want to make an Ajax call on page unload event, but I’m facing a problem to implement it.

Answers (1)

Add Answer
Staff answered 2 weeks ago

Hi Jaimin,

Try the below code.

$(window).on('unload', function () {
   var fd = new FormData();
   fd.append('UserId', UserId);
   navigator.sendBeacon("Your_Url", fd);
});

 

Subscribe

Select Categories