Alert user on database change
I have a bugtracker and eveytime a new bug is added to the database the other users online have to refresh the page to know about it.
Is it possible to alert the users about a new b开发者_运维知识库ug added?
I'm using PHP and MySQL
Thanks in advance.
You mean alerting without page refresh? AJAX could get this done for you, these steps should be taken:
1) Create a php script that fetches the new bugs
2) Add a javascript function that gets the data off the PHP file using getAJAX/getJSON
3) If there is any new data: create an alert or perhaps make a nice looking CSS popup in one corner (or middle) of the screen
Be aware that:
1) You should send some kind of unique identification of a user along with the request to the PHP file, this way you can 'track' which user should have been notified about a bug already.
2) You choose a good interval (e.g. would u use 5 seconds, 2 seconds, 1 seconde, even less?)
You can send an AJAX request to the server every minute asking for changed.
You could include a meta refresh in the page to keep it reloading every few minutes.
Alternatively you could write some gnarly javascript/ajax and alert the user in a modal window/alert box that the current page has changed.
I'm guessing that you don't mean you want to email the other users to notify them?
精彩评论