How to monitor the new content in the database, and the page will be automatically refreshed immediately

Source: Internet
Author: User
How can I monitor the newly added content in the database and automatically refresh the page immediately? how can I monitor the newly added content in the database and automatically refresh the page immediately? Php?


Reply to discussion (solution)

"Automatically refresh the page", the best way is to use ajax to poll

Send a request to the backend to check whether the database has been updated, refresh, or no updates at intervals (for example, five seconds ).

Ajax ?? Check ????? The latest id. if yes? If it is different from the cookie value you saved? Update, same? Set the new id? Cookie


Ajax timed request.
How can I monitor the newly added content in the database and automatically refresh the page immediately? Php?

In the html5 era, event-stream can be used.

The common practice is ajax. of course, you can also use the method of regularly refreshing the page-or...

In the html5 era, event-stream can be used.

Event-stream has a disadvantage. it does not support IE well. it is not suitable for the current situation in China.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.