title: XMLHttpRequest Post Data not being sent
body: <p>This is the javascript:</p>
  
  <pre><code>function eAC(emailData) {
      if (window.XMLHttpRequest) {
          httpRequest = new XMLHttpRequest();
      }
  
      if (!httpRequest) {
          return false;
      }
  
      console.log(emailData);
  
      var fd = new FormData();
      fd.append("email", emailData);
  
      httpRequest.onreadystatechange = eAC_callback; 
      httpRequest.open('POST', "http://website.com/file.php");
      httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      httpRequest.send(fd);
  }
  
  function eAC_callback() {
      if (httpRequest.readyState === 4) {
          if (httpRequest.status === 200) {
              var response = JSON.parse(httpRequest.responseText);
                  console.log(response);
          } else {
              return false;
          }
      }
  };
  </code></pre>
  
  <p>This is the php:</p>
  
  <pre><code>$pec_result = array();
  
  if(isset($_POST['email']) &amp;&amp; strlen($_POST['email']) &gt; 0){
      $pec_result['error'] = 'Its good';
      echo json_encode($pec_result);
      die();
  } else {
      $pec_result['error'] = $_POST['email'];
      echo json_encode($pec_result);
      die();
  }
  </code></pre>
  
  <p>The problem here is that <code>$_POST['email']</code> has a value of <code>NULL</code>. Why is $_POST['email'] null when console.log() for <code>emailData</code> returns a value. Can anyone help? I think the prob is in the appending part. (Not sure)</p>
  
  <p><strong>Please no jQuery</strong>. I know how to do this in jQuery but I want to learn how to do this in javascript. So yeah thanks</p>