开发者

Alert user on database change

开发者 https://www.devze.com 2023-03-03 18:33 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消