2017-04-17 53 views
-2

這就是我所知道的,我想在定時器清零後重新裝入主頁,如果可能的話可能更新mysql數據庫使用php。定時器到達零後清除超時

<script type="text/javascript"> 
setInterval(function() 
{ 
    timezone: 'Africa/Lagos'; 
    var xmlhttp = new XMLHttpRequest(); 
    xmlhttp.open("GET", "request_rec.php", false); 
    xmlhttp.send(null); 
    var timer = document.getElementById("response").innerHTML = xmlhttp.responseText; 
}, 1000); 

if(xmlhttp.responseText < 1) 
{ 
    clearTimeout(timer); 
    location.reload(); 
} 
</script> 
+0

你有一個區間,所以'clearInterval()'是相關的函數,但是你傳遞它的值需要從'setInterval()'返回的值,而不是來自你的Ajax響應的值。 – nnnnnn

回答

2

我覺得你要找的是setTimeout()而不是setInterval()。
閱讀差異here