如何在 jQuery 中为 getJSON 设置缓存 false? [英] How to set cache false for getJSON in jQuery?
本文介绍了如何在 jQuery 中为 getJSON 设置缓存 false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 getJSON
从服务器端获取结果,但面临浏览器缓存问题.我希望缓存为假.我在 getJSON
调用之前尝试使用它.
I am using getJSON
to fetch the results from server side but facing browser cache problems. I want the cache to be false. I tried using this just before my getJSON
call.
$.ajaxSetup({
cache: false
})
但是我没有得到预期的结果.它仍然显示旧的结果.
But I am not getting the expected results. It still shows the old results.
我还确定了一些其他解决方案,例如使用 .ajax
,但我真的不想使用它.
I also identified some other solutions such as using .ajax
but I really don't want to use that.
推荐答案
您的代码只需要一个触发器即可启用.
Your code just needs a trigger for it to be enabled.
这将允许您在以后的所有 ajax 中禁用缓存
This will allow you to disable cache in all future ajax
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
希望有帮助:)
这篇关于如何在 jQuery 中为 getJSON 设置缓存 false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文