简体   繁体   English

无法使setInterval正常工作

[英]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. 我正在将数据输入到Google Spreadsheets,然后将其发布到Web上,并使用一个名为Sheetrock的jQuery插件将其加载到表格中,所有这些都能很好地工作。 But I'm trying to use 'setInterval' so as to reload the data every few seconds but I can't get it to work; 但是我正在尝试使用“ setInterval”,以便每隔几秒钟重新加载一次数据,但是我无法使其正常工作。 the table takes 3 seconds to load initially but then never reloads again. 该表最初需要3秒钟的时间加载,但之后再也不会重新加载。

Here is a jsFiddle of the example I've been working with, and the setInterval code I've added is below, thanks for reading. 这是我正在使用的示例的jsFiddle ,下面添加了我的setInterval代码,感谢阅读。

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

I do alter on you code : check it : 我对您的代码做了修改:检查一​​下:

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

Working DEMO 工作演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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