'Javascript onunload not working when idle for a few minutes
I have a web page that calls a post request just before the user tries to exit the page. I am using the window.onbeforeunload event to achieve that. It works when I leave the page a few seconds after I enter the page, but it doesn't when I stay idle for a few minutes. Here's my Javascript:
window.onbeforeunload = function() {
$.post('http://52.91.227.233:1000/set_day',
{username: user, useday: day}
);
};
According to my observation, there's no problem with the post request or the NodeJS app. It is a problem in the onbeforeunload event, though I don't know what exactly the problem is. I've also tried beforeunload but it still doesn't work
Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
