-1

I am developing a website that has a receptionist page and a user page with multiple user logins. The logged in users are displayed in a table at the receptionist page and one of the columns of the table is the status of the user ( ready or busy). The table is refreshed using ajax every 5 seconds to prevent the web page from refreshing. Each user can log in ( with thier own page) and change their status( ready to busy or busy to ready).

The table is stored in a sql database.

The user page has the option to change the state of the logged in user from ready to busy ( or vice verse) with a drop down menu and a submit button. What i need is to also send and alert or sound to the receptionist page whenever any user switches to the ready state.

I have looked all over the internet but none of the answers have worked for me.

Thanks for your replies. I understand that I could use ajax to query the database to see if a user is ready, however that will cause it to make a notification every time it checks. What i need is for the receptionist to be notified only 1 time each time that a user sets status to ready. I was thinking of making another table that gets updated every time a user changes their status to ready and time stamp it. So that if there is a change in the time stamp it means that some one newly updated it so the signal should be sent.

I made the table and made a php page that returns a string with the time stamp of the table but i dont know how to use the returned string in java script.

  • Check this link may be useful to you http://stackoverflow.com/questions/879152/how-do-i-make-javascript-beep – Vijai Oct 21 '16 at 22:31
  • You don't need communication between tabs,just use ajax to check that value in table ,nothing special.If you do like this you can also check if player logged off – O.Rares Oct 21 '16 at 22:32
  • thanks for your reply. I understand that i could use ajax to query the database to see if a user is ready, however that will cause it to make a notification every time it checks. What i need s for the receptionist to be notified only 1 time each time that a user sets status to ready. – Hector Borges Oct 22 '16 at 20:40

2 Answers2

0

I figured it out. I made an SQL table with a time stamp, whenever any user sets their status to ready the time stamp gets updated. I made a java script that reads the time stamp every few seconds. If the time stamp is different than the initial time stamp then a sound is played.

-1

@O.Rases gave you the best solution.I did something like this in past using ajax and php. A solution can be the following. 1 Every 10s, sent a Ajax call to the server.

2 In the server, using php, you can select users that changed their status in the last 11s (+1s for time-consuming script in the server).

3 after selection is done, sent the user back to the receptionist page. hope it helps

youssouf
  • 381
  • 2
  • 11