title: Get JSON data from AJAX POST send
body: <p>I need to get some JSON data from and AJAX function in PHP
  This is what i've written so far but not sure exactly what to do on the PHP side.
  JS:</p>
  
  <pre><code>window.onload = function() {
      var json = {
          hello : 'howareyou',
          good : 'yes i am good',
          toast : 'i love toast'
      }
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function() {
          if(xhr.readyState == 4 &amp;&amp; xhr.status == 200) {
              alert(xhr.responseText);
          } else {
              alert("no");
          }
      }
      xhr.open('POST', 'json.php', true);
      xhr.send(json);
  }
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['json']) ){
      $json = $_POST ['json'];
      $json_d = json_decode($json);
      echo $json . 'hello';
  } else {
      echo 'error';
  }
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript" src='ajax.js'&gt;&lt;/script&gt;
  &lt;body&gt;
  HELLO THERE THIS IS AN HTML PAGEEEEE
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>