I am trying to execute a function when the user tries to change url, close tab etc. The issue is that when user refreshes/clicks on hyperlink/changes url, the url is updated but the page remains exactly the same.
The problem is especially severe with latest Firefox (did not notice it before for some reason). Chromium on the other hand will wait a few seconds before closing the tab, giving it an awkward, laggy feeling.
The code as it is:
$(window).on('unload', function() {
$.ajax({
type: 'POST',
url: 'ajax/whattodo.php',
async: false,
data: {
method: 'iquit',
exitdata1: exitdata1,
exitdata2: exitdata2
}
});
});
If I remove "async:false" the problem is no longer there. But neither are functions executed. What to do? The page not redirecting is especially annoying, and confusing for the user.