title: passing a javascript variable to PHP with xmlhttprequest
body: <p>Im having problem Posting a javascript variable to a php file. Please would someone tell me what's going on?</p>
  
  <pre><code>// Get Cookies
  var getCookies = document.cookie;
  cookiearray  = getCookies.split(';');
  
  SelectedIds = cookiearray[0];
  
  //take key value pair 
  
   name = cookiearray[0].split('=')[0];
   value = cookiearray[0].split('=')[1]; // The variable(values) i want to pass
  
  // Create our XMLHttpRequest object
  var hr = new XMLHttpRequest();
  
  hr.open("POST", url, true);
  var url = "page.php";
  
  hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  hr.onreadystatechange = function() {
      if(hr.readyState == 4 &amp;&amp; hr.status == 200) {
          var return_data = hr.responseText;
          document.getElementById("Comp").innerHTML = return_data;
      }
  }
  
  hr.send(value); // Request - Send this variable to PHP
  document.getElementById("Comp").innerHTML = "loading...";
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code> $test = $_POST['value'];
   print_r($test); // NULL
  </code></pre>
  
  <p>Thanks</p>