2015-09-13 28 views
0

我有這段代碼,它從Google Spreadsheet生成一個HTML表格。我試圖使僅在表格自動刷新每5秒,而電子表格加載。但是,使用下面的代碼時,只會讓表格在5秒後消失。有人看到有什麼錯誤或有更好的解決方案嗎?自動重新加載HTML表格只是讓它消失

<div class="sheetstotables"></div> 
<script type="text/javascript"> 
var tableId = "AB12C" 
var x = document.createElement("script"); x.type = "text/javascript"; x.async = true; 
x.src = "http://www.sheetstotables.com/get_table.js"; 
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(x, s); 
</script> 


    <script> 
function autoRefresh_div() 
{ 
     $(".sheetstotables").load("load.html");// a function which will load data from other file after x seconds 
    } 

    setInterval('autoRefresh_div()', 5000); // refresh div after 5 secs 
      </script> 
+1

使用F12中的「網絡」選項卡,查看返回的數據。 – maowtm

+0

什麼是F12?你的意思是在鍵盤上......我正在使用一個mac,其中F12只是彈出鍵。 –

+0

無論您使用哪種瀏覽器,都會有一個選項稱爲**開發人員工具**,只需檢查您是否收到任何錯誤或通過** http響應接收了哪些數據** – Rayon

回答

0

您不能在本地運行(您必須在服務器上運行此操作)。試着通過創建一個回購把它放在github.io上。命名爲yourgithubname .github.io或將其放在您自己的服務器上並再次運行。


你只能使用load如果URL開始與任何如下:

http://data:chrome://chrome-extension://https://chrome-extension-resource

如果你的網址是file:///,那麼你不能這樣做。