จาวาสคริปต์ setinterval
setInterval(function(){
console.log("Oooo Yeaaa!");
}, 2000);//run this thang every 2 seconds
jquery เรียกฟังก์ชันทุกวินาที
setInterval(function(){
//this code runs every second
}, 1000);
จาวาสคริปต์ setinterval
setInterval(function(){
console.log("print this once every 3 second");
}, 3000);//run this thang every 3 seconds
จาวาสคริปต์ตัวเลือกการขอข้อมูลจำนวนครั้งแล้ว
var x = 0;
var intervalID = setInterval(function () {
// Your logic here
if (++x === 5) {
window.clearInterval(intervalID);
}
}, 1000);