Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!