I am using onbeforeunload event to send ajax request to perform some clean up task.
When I am using onbeforeunload, it shows the confirmation dialog on closing the t
As per my comments on the original post, the answer is to make the call synchronous by adding async: false
in the Ajax call settings, change the last return false to return null;
, and remove the done function:
window.onbeforeunload = unloadFunction;
function unloadFunction() {
var test_id = $('#test_id').val();
jQuery.ajax({
url: "/test/cleanup/" + test_id,
cache: false,
async: false
});
return null;
}