I have a system that marks whether the person is available or unavailable . There is a button called exit . If the person clicks on it when it is available, then it automatically changes the status of the database to unavailable. Only some site users are clicking on the X , so the person is still available but in fact it is no longer logged in to the site. I've been researching and some people were talking about using the unload
or onBeforeUnload
function because the two have a difference. I would like to know which of these two to use and if by chance someone knows how to make a $ post request with jQuery when the person clicks on X