天天看點

setInterval和setTimeOut方法—— 定時重新整理

setInterval 是設定時間反複調用函數的方法;

setTimeOut 是個延時方法, 設定在多長時間後才開始執行一次;

setInterval定時重新整理應用-如:

$(document).ready(function () { 

setInterval(refreshMeetInfo, 5000); 

});

function refreshMeetInfo() { 

$.ajax({ 

type:'post', 

url:'bookShop.do?parameter=refreshMeetInfo', 

cache:false, 

async:true, 

success:function(booklist){ 

……

}); 

}

setTimeOut延時應用如:

$(document).ready(function () {

$("#date").text((new Date()).toString());

window.setTimeout(function () {

location.reload();

}, 1000);

本文轉自linzheng 51CTO部落格,原文連結:http://blog.51cto.com/linzheng/1080888