I have written code which gets the JSON file and work on it. But that file gets updated every 5 minutes. So I want my code to get the fresh data without causing refresh.
Here is how I am getting the JSON file.
$.getJSON("new_json_file.json", function (data) {
$.each(data, function (i, item) {
//Here I am working on the data
});
});
Can anyone help?
Wrap your code in a function and then it can use setTimeout to run itself again 5 minutes later...
function getData() {
$.getJSON("new_json_file.json", function (data) {
$.each(data, function (i, item) {
//Here I am working on the data
});
setTimeout(getData, 300000);
});
}
getData(); // run once to start it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With