Hi,
I want to logout my when the chrome browser tab is closed. I am using the below code:

var validNavigation = false;
function goodbye() {
if (!validNavigation) {
if (window.XMLHttpRequest)
{
var request = new XMLHttpRequest();
request.open("POST", "logout_admin.php", true);
request.onreadystatechange = function () {
if ( request.readyState == 4 && request.status == 200 )
{
console.log("Succes!"); //alert("Succes!");
}
};
request.send();
}
}
}

$(window).bind('beforeunload', function(e) {
var x =goodbye();
return '';
});

The above code is working and askking the conformation when closing the chrome browser tab.

If i remove return ''; above code then conformation box is not showing. But unable to logged out.

Please give me suggestions for onbeforeunload regarding the chrome browser.

Thanks in advance ....