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
            })

但我没有得到预期的结果.它仍然显示了旧的结果.

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.

This will allow you to disable cache in all future ajax

$(document).ready(function() {
  $.ajaxSetup({ cache: false });
});

Hope it helps :)

Jquery相关问答推荐

更改后如何使用 jQuery Select CSS 类

Jquery 表数据无法在 html 上正确显示

使用 Bootstrap 3 下拉菜单作为上下文菜单

jQuery 或 JavaScript 中的$符号是什么意思?

如何在 jQuery 中使用:not 和 hasClass() 来获取没有类的特定元素

获取单选按钮组的值

如何使用 JQuery 发布 JSON 数据?

动态设置 iframe src

从 iframe 访问父窗口的元素

试图检测浏览器关闭事件

jQuery $.cookie 不是一个函数

如何在 JavaScript 或 jQuery 中规范化 HTML?

即时替换 css 文件(并将新样式应用于页面)

如何触发href元素的点击事件

使用 jQuery 按字母顺序对选项元素进行排序

JQuery:如果 div 可见

Fancybox 不适用于 jQuery v1.9.0 [ f.browser 未定义 / 无法读取属性 'msie' ]

Uncaught TypeError: undefined is not a function on loading jquery-min.js

如何在文件 Select 上触发事件

使用 jQuery/Javascript 防止任何形式的页面刷新