-2

I have two files, index.php and table.php. My table.php is included in index.php file in a div. For that, I did it as:

$("#tableloader").load('table.php')

My table.php changes every second. So to reflect it changes in the index.php file I tried:

function get_table() {
      $("#tableloader").load('table.php')
    }
    setTimeout( get_table, 1000 );

But it loads the table.php only once, not every second...

Chirag Jain
  • 1,367
  • 1
  • 11
  • 27
adam
  • 3
  • 2

2 Answers2

4

You are using setTimeout(), which is just to launch a function at a specified time. Use setInterval for getting desired result.

function get_table() {
    $("#tableloader").load('table.php')
}

window.setInterval(function(){
    get_table();
}, 1000);
Chirag Jain
  • 1,367
  • 1
  • 11
  • 27
1

You are using setTimeout - calls a function after certain time. So, it will call your function once after 1 second.

You need to use:

setInterval - It will call your function after every 1 second.

Please have a look here.

Siri
  • 1,117
  • 6
  • 13