user478636 user478636 - 5 months ago 18
PHP Question

notification system in PHP/jQuery

I want to program some sort of notification system. What would be the be the best way to achieve this?

  1. By calling Ajax request call to database on page load? But the problem with this is that it only checks on page load. It would be better if it was even realtime, I guess that depends on the priority of the message. How would I go about on achieving this?

  2. By using cookies?

I am using PHP and jquery.

Answer Source

Like you said, it depends on message priority.

If notifications are made upon the visitor performing an action, it would be easy to tie in session-based notifications.

If notifications are made upon other users performing an action (e.g. "John made an edit to this page. Click here to view."), you could use long-polling AJAX to wait for a notification.