简体   繁体   中英

Auto refresh table by javascript

I am trying to make a table in an HTML/PHP page auto refresh every 10 seconds. In this table, a chart from Google Spreadsheet is embedded. What am I doing wrong?

Fiddle

var counter = 0;
window.setInterval("refreshDiv()", 10000);
function refreshDiv(){
    counter = counter + 1;
    document.getElementById("google");
}

As per documentation setInterval() receives two parameters. The first one is a function and the second one is milliseconds to wait till next execution.

You're passing a string as the first parameter. Here you are a way where refreshDiv function gets executed.

var counter = 0;

var refreshDiv = function () {
  console.log( 'Hey! I was called!!!' );
  counter = counter + 1;
  document.getElementById( "google" );
}

window.setInterval(refreshDiv, 10000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM