我有一个在我文档的 head 标签中调用的 javascript 文件,每隔 30 秒,我希望重新加载这个 javascript 文件。
我对此做了一些研究,似乎它在提取本地存储的文件副本或跨浏览器问题时存在问题...
从缓存中提取它不是问题,因为实际文件并没有改变,它只需要重新加载。
这会是一个 ajax 任务吗? 我该怎么做呢?
提前致谢。
最佳答案
function foo(){
$.getScript( url, function(script, textStatus, jqXHR){
script...
});
}
setInterval(foo, 30000);
Caching Responses
Be default, $.getScript() sets the cache setting to false. This appends a timestamped query parameter to the request URL to ensure that the browser downloads the script each time it is requested.
关于javascript - 定时 Javascript 文件刷新而不重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11004113/