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);
});