While attempting a synchronous ajax request during the beforeunload event, I encountered an error stating that synchronous ajax requests are not supported in chromium browsers during page unload events.
I am seeking alternatives for making a synchronous ajax request during the page unload event cycle.
window.on('beforeunload',function(){
$.ajax({
url:'@Url.Action("ActionName","ControllerName")',
async:false,
data:formData,
success:function(){
//Success logic
},
error:function(){
//Failure logic
}
});
});
DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load:
Note: navigator.sendBeacon() is asynchronous by default, but i need to have a synchronous request in page dismissal.
If you have any suggestions or workarounds, please share them.