Reputation: 752
On selection change of radio button, I want to show a clock/timer for 5 minutes and set a lock in DB.
Once 5 minutes are over, I have to remove the lock.
Also in case the browser window has been closed or redirected to other page, I should remove the lock.
Any pointers on how to achieve this functionality?
Are there any built-in clocks/timers ?
Thanks in Advance.
Upvotes: 0
Views: 306
Reputation: 7200
I would use jQuery to wire up the click() handler, and you can use the setTimeout() method to call a function after 5 minutes
setTimeout(function() { /* your ajax call here */ }, 5000);
For more information on detecting when the browser closes, see this question:
javascript detect browser close tab/close browser
Upvotes: 2