Richard-MX
Richard-MX

Reputation: 484

How to make notifications under certain time via javascript?

I'll try to keep this brief. Hope to get some help or directions about this. Im creating a webapp for a customer that needs notifications for something like this case.

A client register to the hotel at 10PM for 12 hours, this person will left the hotel at 10AM. My client wants a way to display a notification when there is 10 minutes to run out of time for the customer at hotel. I mean, at 9:50AM, the system should display a notification saying: "Time for Room 212 it's gonna expire soom. Contact him and ask if he wants extra hours".

Im using PHP and JQuery for this mission. The whole thing is to figure out a way to check the end-time for the customer and display a notification 10 mins before that end-time. I don't know how to keep "checking the end-time" constantly and display the notification when is the right time.

I hope i've explained my self about this. Any direction, anything that works for this, anything will be very welcome.

Thanks in advance.

Upvotes: 1

Views: 887

Answers (2)

ValeriiVasin
ValeriiVasin

Reputation: 8706

I advice you to use jQuery timers plugin for actions explained in previous post.

As way for you is creating notificator that will ask server every minute for the messages. It will be like that:

$(document).everyTime('1min', function(){
  // your request function
});

In your request you don't need send any data (of course if your server knows your timezone).

And server will respond you after DB reques as FALSE if no notifications at the time or with notification / array of notifications (of course as json-object).

Good Luck!

Upvotes: 1

mephisto123
mephisto123

Reputation: 1448

setInterval(function() {
   // check the time, if it is 10 min before end-time, display notification
}, 1000);

Upvotes: 0

Related Questions