I want to make counter, which value will be the same for all users.
I have json file, which contains data: count = 0.
I want to run function every second which will be doing next:
1.Get value from json file
2.Update counter value
3.Change value in json file
4.Go to 1
Here is what I have now:
var counter = 0;
var myCounter = new flipCounter('counter', {value:counter});//initializing counter
window.setInterval(function(){
$.getJSON('http://127.0.0.1:3000/counter.json', function(data) {1.taking the data from file
myCounter.setValue(data.count);//2.Updating counter
//3.here I need to change value from json file
})
}, 1000);
Can someone help me with point 3( How to change json value from jQuery ) ?
counter.jsonfile? If so, you won't be able to do that with just javascript. You will need some server-side language to handle that. So you could basically POST your updated json and have the server code use it to write to the json file.