thekingsrook thekingsrook - 1 month ago 10
jQuery Question

Can't get setInterval to work properly

I'm inputting data to Google Spreadsheets, publishing it to the web and loading it into a table using a jQuery plugin called Sheetrock, all of which works well. But I'm trying to use 'setInterval' so as to reload the data every few seconds but I can't get it to work; the table takes 3 seconds to load initially but then never reloads again.

Here is a jsFiddle of the example I've been working with, and the setInterval code I've added is below, thanks for reading.

$( document ).ready(function() {
setInterval(function() {
$('#statistics').sheetrock({
url: mySpreadsheet,
})
}, 3000);
});

Answer

I do alter on you code : check it :

  $( document ).ready(function() {
      setInterval(function() {
           $('#statistics').load(mySpreadsheet)
        }, 3000);
    });

Working DEMO