如何每小时自动调用javascript函数? [英] How to automatically call javascript function every hour?

查看:22
本文介绍了如何每小时自动调用javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从 URL 获取 JSON 对象的 javascript 函数,我想每小时用最新的数据刷新 JSON 对象.

I have a javascript function that gets a JSON object from a URL and I want to refresh the JSON object every hour with up to date data.

我假设这样做的方法是调用每小时从 URL 获取 JSON 对象的 javascript 函数.

I am assuming the way to do this is to recall the javascript function that gets the JSON object from a URL every hour.

但是我不知道如何设置一个函数以每小时自动重新运行,有人可以解释一下这是如何完成的吗?

However I do not know how to set a function to automatically rerun every hour, could someone explain how this is done?

谢谢

推荐答案

function doSomething()
{
    alert('Test');
}


setInterval(doSomething, 60*60*1000);

这篇关于如何每小时自动调用javascript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆