Sending ajax when user closes browser window [duplicate]
问题 This question already has answers here : JavaScript, browsers, window close - send an AJAX request or run a script on window closing (9 answers) Closed 4 years ago . My Main GOAL and actual scenario: If two users share the same credentials, then the second user can not login into the system until the first one who is already logged in, log outs system. Actually I want to set login_flag=0 on server database, when user closes the browser window. I googled and figured out to send an ajax request