如何在jQuery中将getJSON的缓存设置为false? [英] How to set cache false for getJSON in jQuery?

查看:226
本文介绍了如何在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屋!

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