I am trying to prevent the client from disconnecting from the server. Therefore, before the user closes the window in which the application is open, I:
$(window).bind("beforeunload", function() {
return("Close the app?");
});
But the problem is that regardless of whether the user chooses to leave or stay on the page where the application is open, the client disconnects (stops listening) from the server before I even chose the option. Therefore, if the user decides to stay on the page, nothing will be sent or received from the server.
Why could this be? How can this be prevented?
source
share