Q: Sync Data between clients and server? I'm newer to web design and I'm making a super simple website that a few friends of mine can use when they play DnD, it's meant to display health values that can be changed and update in real time.
As I mentioned: I'm newer to web design. Does anyone have a good recommendation of where to begin when it comes to syncing data between clients and the server? When someone clicks a button to increase or decrease a value, how would I get that change to reflect on each client's browser?
Here's my current guess. Would it be a good idea to use JSON files to shoot data in between clients and the server? I'm only expecting one person to be messing with values at a time. I've started looking into JSON but I'd like to get a second opinion.
I'm looking for the simplest way to accomplish this. I'd like to stay away from something that may require more knowledge than I currently have though I do understand that I may need to do a lot more learning in order to learn this. Thanks a ton in advance for your time!
EDIT: Here's my code to read from the JSON file. It works.
setInterval(function(){
   $.getJSON('json/file.json', function (data) {
   console.log(data);
   document.getElementById("entityOneHealth").innerText = "Health: " + data.health1;
   document.getElementById("entityTwoHealth").innerText = "Health: " + data.health2;
  });
}, 1000);

So I can get it to read from the JSON file now, all I need is to figure out how to save changes to the values and store them/overwrite the json file so it can be updated across all clients. What's the best way to go about this?
EDIT 2:
After doing some research it looks like this should do something similar to what I need, but it gives me a "not well formed error". Javascript below:
var rawData = {
"health1": 4,
"health2": 6
};

$.ajax({
   type : "POST",
   url : "some.php",
   data : {
    json : JSON.stringify(rawData)
   }
});

And my PHP file:
$json = $_POST['json'];

if (json_decode($json) != null)
{
  $file = fopen('json/your_array.json','w+');
  fwrite($file, $json);
  fclose($file);
}
else
{

}

Any ideas why it wont work?
