问题
So I have an external script that will sometimes input something into a sql database throughout the day (usually about 3 times a day, but could potentially update ever minute) I need to find a way to make the html page (that displays the sql entries) refresh automatically when there is a new entry that's added. Any suggestions for PHP and SQL? I was thinking Ajax, but I'm pretty sure I will need to do a full page refresh, because it will update images too.
回答1:
You need a way to let the browser know that the data has been updated.
The easiest way would be to have an ajax call that pools the server to check if new data has been added. You can use javascript to set this to be called every minute or however often you want. Once the ajax call shows that new data has been loaded, then you can use javascript to refresh the page.
This approach will mean you have a lot of calls to your server, but they will be small and the full data will only be loaded when needed.
来源:https://stackoverflow.com/questions/3972065/refresh-html-page-when-a-new-sql-entry-has-been-inputted