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

I'm reading a JSON file with jQuery. If I update the file that .get() reads it still gets the old

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742330704a4423661.html

相关推荐

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

    I'm reading a JSON file with jQuery. If I update the file that .get() reads it still gets the old

    6小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信