我想在5秒后更新此查询,以刷新div
function cart_count(){
$.ajax({
url : "functions.php",
method : "POST",
data : {cart_count:1},
success : function(data){
$(".badge").html(data);
}
})
}
答案 0 :(得分:0)
使用JS setInterval()
,如:
setInterval(function(){ alert("Hello"); }, 5000); // It will execute the code on every 5 seconds
// Instead of alert("Hello"); put your ajax() code here
答案 1 :(得分:0)
试试这个
(function(){
setTimeout(cart_count(), 5000);
})();