I use onbeforeunload event to send an ajax request to do some cleanup task.
When I use onbeforeunload, it shows a confirmation dialog when closing the tab. I want to not show a confirmation dialog and just send a cleanup request. Below is the script.
window.onbeforeunload = unloadFunction; function unloadFunction() { var test_id = $('#test_id').val(); jQuery.ajax({ url: "/test/cleanup/" + test_id, cache: false }).done(function () { return false; }); return false; }
Is there any way to suppress the confirmation dialog?
According to some suggestions, I tried changing the return statement to return ; instead of return false; . But this also does not work.
source share