Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on attendance system where project management system is also handling using Javascript\Jquery at client side and PHP\MySQL at server side.

A feature in my web app is user message to admin. For this I have applied an ajax request which is made by setTimeout function (after every 15 seconds) to check that is there any new message comes in database if yes then return it to the admin.

It working fine but the drawback is (as you know) continuous request to server which really poor and bad. As I know that real time functionality can solve this problem I have checked some link websocket.io and signlR but there are applicable with Nodejs and asp.net.
So, how can I apply real time functionality with php or I get that new data have reached in to database without continues request with ajax.
Posted

1 solution

Why every fifteen seconds ? Who needs to be notified that fine a constraint?

If you really need immediate notifications - why not have the same code that does the MySQL calls to insert/update a record send an email notification, as well (with a time stamp if you need one? This would then be real time but only when an event actually occurs.

 
Share this answer
 
Comments
Muhamad Faizan Khan 6-Apr-15 10:25am    
so you mean send notification as insert command occur in specified table? how?
W Balboos, GHB 6-Apr-15 10:30am    
Do it in your php: check for successful insert - and if there is one you can send whatever data you wish to using SMTP mail.

Alternatively, create an after-insert trigger and then have the trigger's code use the server to send the mail.

For what you don't know how to do, try looking it up . . . (php's SMTP vs SQL trigger).


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900