title: Why does this Ajax request not seem to pass the JS variable through to PHP?
body: <p>I'm currently struggling to figure out how to pass variables from JS to PHP using Ajax. I have tried using the following Ajax code</p>
  
  <pre><code>xhr = new XMLHttpRequest();
  
  function myFunction() {
      xhr.open("GET", "welcome.php");
      xhr.send("your_name=john&amp;your_age=40");
  
      xhr.onreadystatechange = function() {
          if(xhr.readyState === 4) {
              document.getElementById("output").innerHTML = xhr.responseText;
          }
  
      }
  }
  </code></pre>
  
  <p>Combined with a PHP script called welcome.php which looks as follows:</p>
  
  <pre><code>$user = $_GET['your_name'];
  var_dump($user);
  </code></pre>
  
  <p>For some reason, however, this outputs 'NULL' and I can't work out why.</p>
  
  <p>I've also tried including <code>echo $user;</code> in file welcome.php, but this doesn't return anything.</p>
  
  <p>Anyone know why this is happening?</p>