How to listen dB to synchronize it with the page?

Try to reflect changes in the database immediately on the page.
Doing a simple query

function refresh(){
 $.getJSON('get.php', function(response) {
 $.each(response, function(k,v) {
 $('#' +;

works as it should.

Wanted to wrap up in
setInterval(refresh(), 1000);
but still f-I is called once when the page loads.
April 7th 20 at 15:52
2 answers
April 7th 20 at 15:54
So you need:
setInterval(refresh, 1000);

But such things make little differently, usually with web sockets.
Your function will every second to do the query to the server, the function will work with each client, bringing the number of requests to the server will be in multiples to grow the number of customers. While more than half of the queries are useless.

More logical to make a web socket connection to the client is run once per second to the server and so the server kindly sent to the client event data only for the fact of their updating.

and more options are there? Google tables on websocket done?

About web sockets thanks, interesting - Zack.Howe27 commented on April 7th 20 at 15:57
April 7th 20 at 15:56
Because you are using setInterval incorrectly.
Pass refresh instead of refresh()

Read more about timers in js search it in Google

Find more questions by tags AJAXjQuery