问题描述
我是用我们的仪表盘下面的code,不断刷新无闪烁https://stackoverflow.com/questions/5404839/how-can-i-refresh-a-page-with-jquery/7609411#comment32918089_7609411
I am using the following code on our dashboard to refresh it constantly without flicker https://stackoverflow.com/questions/5404839/how-can-i-refresh-a-page-with-jquery/7609411#comment32918089_7609411:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
setTimeout(function() {
$.ajax({
url: "",
context: document.body,
success: function(s,x){
$(this).html(s);
}
});
}, 4000);
</script>
不过,这是造成的JavaScript每次也由于一些缓存断路器重新加载。
However, this is causing the javascript to reload each time too due to some cache breakers.
谷歌发送有以下标题:
在没有得到我和我的客户从谷歌封锁的利益(可能也成为一个门诺在这一点上)有没有办法使用谷歌的CDN,而不会导致这些额外的要求?
In the interest of not getting myself and my clients blocked from Google (might as well become a Mennonite at that point) is there a way use Google CDN without causing these extra requests?
推荐答案
警告未经测试的:
$.ajax({
url: "",
dataType: "text", //dont parse the html you're going to do it manually
success: function(html) {
var $newDoc = $.parseHTML(html, document, false); //false to prevent scripts from being parsed.
$('body').replaceWith(newDoc.find("body")); //only replace body
}
});
有一个更好的解决办法是模板自己的身体。
A better solution would be to template your body.
这篇关于谷歌托管库被不必要地使用缓存断路器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!