I have following scenario where jquery ajax call is fail.
I want to save user information in database when user close browser/ leave a webpage. So for that I am making an Ajax call from
window.onbeforeunload =function() {
}
function. Below is a sample code.
window.onbeforeunload = function () {
$.ajax({
Async: false,
cache: false,
dataType: 'json',
data: Idata,
url: url
});
}
This Ajax call fails from Firefox. It is working fine with IE and Chrome.
Now if I add a return statement in the above code. For example
window.onbeforeunload = function () {
$.ajax({
Async: false,
cache: false,
dataType: 'json',
data: Idata,
url: url
});
return true;
}
And I try to leave webpage then it will show a webpage leaving message. And also it makes an Ajax call from Firefox. But I don't want to show a browser web page leaving messages when user is leaving webpage.
Is it mean firefox is suppressing an Ajax call when return statement isn't specify in code?
This same problem is also occurred with Safari.