0

Usually I make content refresh automatically with the javascript function using setInterval. But it seems ineffective because every second the content must be reloaded will take up a lot of resources.

Therefore if there is another alternative to creating an automatic refresh function only when the data has changed in the database.

3
  • Integrate websocket in php and listen for changes in javascript and refresh on changes Ref: Websockets in PHP Commented Jun 19, 2020 at 2:57
  • Thank you for your alternative solution. Maybe i am newbie :( need an example simple project which is integrated with the mysql database. Commented Jun 19, 2020 at 3:10
  • If the resources are at the database layer, include SHOW CREATE TABLE {tablename} and the SQL to retrieve it. What would the SQL be to retrieve the changes? How are database changes occuring and could you use a websocket to pipe raw new results from whatever changes it. Commented Jun 19, 2020 at 4:08

1 Answer 1

1

One way to update your data would be to use Ajax in the frontend to request the data every few seconds and update it instead of reloading the page. Otherwise, you should check out socket.io (websockets)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.