Haka Ton
Haka Ton

Reputation: 11

Using old version of JSON when the JSON is updated and the page is refreshed

I have question about JSON and JavaScript. So through web page I update JSON file and then save it to the server. Then I go to the page where there must be listed the information from the JSON but it visualisates the old information of the JSON even after refreshing the page. Only when I open a new window of web browser then it list the latest JSON. I search for any cache but there is nothing and don't know where is the problem. So how to visualisate the updated JSON after refreshing page?

I am fethching the information by jQuery:

$.getJSON("json2.json", function(json) {
console.log(json[0]); // this will show the info it in firebug console
var count = Object.keys(json).length;
console.log(count);
for(var i=0; i<count; i++){}});

This is no the full code but i can't publish it all because it so long.

Upvotes: 1

Views: 198

Answers (1)

Louys Patrice Bessette
Louys Patrice Bessette

Reputation: 33933

This is probably due to browser cache, since this is the same filename.

Add this before your $.getJSON(...:

$.ajaxSetup({
    cache:false
});

;)

Upvotes: 1

Related Questions