2011-01-06 50 views

回答

0

您可以使用setInterval javascript函數,它允許您定期執行一些代碼。然後,您可以向服務器發送AJAX請求,以查看是否有更新並刷新頁面的某個部分。下面是一個如何輪詢更新服務器動作的示例:

window.setInterval(function() { 
    // this will execute every 5 seconds 
    // send an AJAX request 
    $.get('/someaction', { }, function(result) { 
     // use the result returned from the server 
     // to update the DOM 
    }); 
}, 5000);