title: JS script calls a PHP script but then I can't handle the JSON for the html
body: <p>I'm a beginner and I'm writing a js function that every 1 second it calls a PHP script where it checks some values on mysql DB, PHP encodes them in Json, then JS again decode it and throw them into html.</p>
  
  <p>I have two questions for you:</p>
  
  <p>-Why do you think this code is not properly working? It only writes the first value into the <code>&lt;p&gt;</code> list.</p>
  
  <p>-How can I make this scalable? Every call to the php script executes a query. I need something like realtime, but I think using this way I'll destroy my server soon xD</p>
  
  <p>JS</p>
  
  <pre><code>setInterval(function(){
  
      $.getJSON("php/checkstatus.php", function(result){
  
                  $("#status").html(result['status']);
                  $("#tempint").html(result['tempint']);
                  $("#tempext").html(result['tempext'] + " ");
                  $("#humidityext").html(result['humidityext'] + " ");
  
  
          });
  
    },1000);
  </code></pre>
  
  <p>The json is like this:</p>
  
  <pre><code>{"status":"0","tempext":"25","tempint":"150","humidityext":"65"}
  </code></pre>
  
  <p>and the HTML is like this:</p>
  
  <pre><code>&lt;p&gt;status: &lt;span id='status'&gt;xx&lt;/span&gt; .&lt;/p&gt;
  &lt;p&gt;Inside temperature: &lt;span id='tempint'&gt;xx&lt;/span&gt; °C&lt;/p&gt;
  &lt;p&gt;Outside temperature: &lt;span id='tempext'&gt;xx&lt;/span&gt; °C&lt;/p&gt;
  &lt;p&gt;Outside humidity: &lt;span id='humidityext'&gt;xx&lt;/span&gt; &lt;/p&gt;
  </code></pre>