最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to clear the cache for JSON - Stack Overflow

programmeradmin2浏览0评论

I'm reading a JSON file with jQuery. If I update the file that .get() reads it still gets the old values when I read the newer file. Since I write and read the file every second, how can I solve this problem? Manually clearing the cache won't be a option.

function readEye() {

    $.getJSON('output.json', function(data){

        console.log(data);

    });

}

I'm reading a JSON file with jQuery. If I update the file that .get() reads it still gets the old values when I read the newer file. Since I write and read the file every second, how can I solve this problem? Manually clearing the cache won't be a option.

function readEye() {

    $.getJSON('output.json', function(data){

        console.log(data);

    });

}
Share Improve this question edited Dec 31, 2011 at 20:12 ThinkingStiff 65.4k30 gold badges147 silver badges241 bronze badges asked Dec 31, 2011 at 19:45 clankill3rclankill3r 9,58322 gold badges76 silver badges131 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

use $.ajaxSetup settings

$.ajaxSetup({
  cache:false
});

after that you can use your code like

function readEye() {
  $.getJSON('output.json', function(data){
    console.log(data);
  });
}
发布评论

评论列表(0)

  1. 暂无评论