title: HTML5 ajax client-server communication and security
body: <p>thanks for your help today. I am creating an HTML5 game and need some help determining the best method for Client Server communications. </p>
  
  <p>I am trying to avoid socket.io for reasons I cannot mention. </p>
  
  <p>The primary thing is that the app needs to be secure(i.e. not open to js injection), while minimizing server load as much as possible</p>
  
  <p>I understand that Ajax is one such method and the Jquery has some easy Ajax methods in its library.</p>
  
  <p>I am not looking for any code, only advice on what the best way to go about this.</p>
  
  <p>Let me provide and over simplified example</p>
  
  <p>I have 1 div, and 2 buttons. The div displays # of coins, the first button adds 1 coin every time it is clicked, the 2nd button is upgrade coins button, which will subtract a certain number of coins.</p>
  
  <p>all of the addition and subtraction of coins will be handled server side. My understanding is if I use session variables to store the data on the server, that they are invulnerable to "cheat engine" or other memory editing tools. Correct me if I am wrong on this.</p>
  
  <p>So when the user clicks the add coin button the coins div will increase by 1 or some greater amount later. I understand that can be done very simply with something like</p>
  
  <pre><code>$("#div1").load("update.php");
  </code></pre>
  
  <p>so is this vulnerable to js injection, inother words can someone alter it to add more than 1 coin when it is clicked, my thinking is probably not.</p>
  
  <p>finally is it possible to update more than 1 element from the same jquery request, for example if I want to change both "div1" and "div2" from the same request or is it best to do that as 2 separate requests? also lets say that there is more than 1 piece of data returned by the request. Is this where a Json file would come in handy?</p>
  
  <p>Thanks</p>