I'm trying to do a jquery .ajax synchronous call on window.onunload. FF and IE works but not on Chrome. I had done some testing and Chrome seems to terminate the window and not wait for the response.
Here is my code:
window.onunload = function() {
$.ajax({
url: "/someurl",
async: false,
data: ({ somedata: "test" }),
success: function(){ return true; },
error: function(){ alert('got some error'); }
});
}
Note that I'm using window.onbeforeunload to display a warning message, then trigger the window.unload when the user leaves the page.