I came accross following code:
<script type="text/javascript">
var timeoutId;
var intervalId;
function doIt(){
$("#main").load("refresh.php");
}
$(document).ready(function(){
timeoutId = setTimeout(function(){
doIt();
intervalId = setInterval(function(){
doIt();
}, 5000); //Request the doIt() method every 5ms.
}, 3000); //Delay calculated on the server to trigger the function at the appropriate time
});
</script>
Rather then calling every 5 second is there any way to call it at 8am everyday in the morning?
$("#main").load("refresh.php");
will load the result from refresh.php page on div with id main right?
You'll have to keep the browser up all the time, because javascript
is a client side language.
Instead use Cron Job , to schedule tasks.
You don't need to call it every morning at 8 AM.
If the browser is open at 8 AM, just make a call to server to get the latest data.
You can use the getHours()
method of date object and check the time. At 8 AM, refresh the data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.