I am creating a Chat application in php.
AIM:
when a user1 invites user2, user2 want to get a alert or popup message that user1 has invites him.
What i have done is –
When user1 invites, the message is stored in database. In user side i used to check whether
Database is updated or not. If database is update i used to show alert. This i done on php and javascript but not working all time.
Is this a good method? Any other method?
All the clients can use jquery and send following request periodically:
To call above code periodically you can use following code in jquery/javascript. This would be making periodic calls and getting the response back to you. As soon as the response come without containing “uninvited” string it gives an alert and also calls the post method function.
This can be repeatedly called with following code.
This will check every 5 seconds if there are any invitations. Alternatively for a more better control jquery plugins like Timer can be used to execute something repeatedly.