Hi there. I load some data from backend from a json file. My problem is: if i change the json file the application don’t get the changes on the json file.
So it looks like it would cache the data from the json file and don’t reload it anymore. Equal if i restart the studio or delete the site data from developer console (developer console / application / clear storage / clear site data).
For example in my json file stands at the start point:
‘text’: ‘i am a text’,
and update it to:
‘text’: ‘i am a awesome text’,
and restart the application it will load everytime:
‘text’: ‘i am a text’
here is my code:
export class Data{
ajaxParam : Z.Ajax.Parameters = {
url : 'http://localhost/media/data.json',
method : "GET",
timeout : 3000,
}
constructor(){}
public getInitData(_callback : Function, _obj){
Z.ajax(this.ajaxParam, (statusCode, data, request) => {
console.log('start ajax');
if (statusCode === 0) {
console.log("Unable to connect - check network connection.");
return;
}
if (statusCode < 200 || statusCode >= 300) {
console.log("HTTP request failed: " + statusCode);
return;
}
// Attempt to parse the data returned from the AJAX request as JSON
let parsedData;
try {
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse
parsedData = JSON.parse(data);
} catch (e) {
console.log("Unable to parse JSON: " + e);
return;
}
// Check the data is as expected and display it
if (parsedData.audio) {
console.log(parsedData.audio);
} else {
console.log("Unexpected response from API");
}
_callback(parsedData, _obj);
});
}
}