Reputation: 9583
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);
});
}
Upvotes: 3
Views: 10703
Reputation: 31043
use $.ajaxSetup
settings
$.ajaxSetup({
cache:false
});
after that you can use your code like
function readEye() {
$.getJSON('output.json', function(data){
console.log(data);
});
}
Upvotes: 5