title: Sending value from AJAX to JSON file
body: <p>I need to send value from AJAX to JSON file so I did it into 2 steps</p>
  
  <ol>
  <li>Send from AJAX to PHP file</li>
  <li>Send from PHP file to JSON</li>
  </ol>
  
  <p>The problem that I can't read JSON file at the same page of saving it</p>
  
  <p>Sending value from AJAX to PHP file (IT WORKS FINE)</p>
  
  <pre><code>$.ajax({
      url: 'php.php',
          type: 'POST',
          data: {id:value},
          success: function(data) {
          console.log(data);
          }
      });
  
  &lt;?php
      $collectionID = file_get_contents('json.json');
  //This php code is in the same page of AJAX, my problem that it doesn't read json at the same time.
  //I must refresh the page to read the old value then the AJAX save a new value and I can't read it also now
  ?&gt;
  </code></pre>
  
  <p>php.php file - write the value into json file (IT WORKS FINE)</p>
  
  <pre><code>file_put_contents('json.json', $_POST['id']);
  </code></pre>
  
  <p>I need to send and save the value from AJAX (UP) then read it again into my php code (DOWN) at the same page!!!</p>
  
  <p>I need to do that because I can't send value from JS to PHP direct, so I sent it from client side (JS) and I received into server side (PHP) .. Now I want to receive it back into client side (PHP) to echo the value</p>