Home  >  Article  >  Web Front-end  >  Implementation method of js executing ajax request every 5 minutes_javascript skills

Implementation method of js executing ajax request every 5 minutes_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:12:051656browse

It seems that a page can only have one window.onload=function(){}, so there must be multiple events, just write it like this

Copy code The code is as follows:

window.onload=function(){
//Assume that the test function is executed every five minutes
publicBusi();
personBusi();
}
function publicBusi(){
setTimeout(personBusi,1000*60*7);//1000 here means there are 1000 milliseconds in one second, 60 seconds in one minute, and 7 means 7 minutes in total
$.post('${basePath}/approval/toCheckPublicBusi',function(data){
if(data.result !=0){
........... ............
}
});
}
function personBusi(){
setTimeout(publicBusi,1000*60*5);// The 1000 here means there are 1000 milliseconds in 1 second, 60 seconds in 1 minute, and 5 means 5 minutes in total
$.post('${basePath}/approval/toCheckPersonBusi',function(data){
if(data .result !=0){
............
}
});
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn