title: Can't Get Custom HTTP Header Response from Ajax getAllResponseHeaders
body: <p>I do get the response data, but I can't get my custom HTTP header data.</p>
  
  <p>Yes, this is a cross-domain request. I am doing an Ajax request with Javascript. I've tried this with XMLHttpRequest and also jQuery $.ajax. I've done my server settings, I have these set when sending data:</p>
  
  <pre><code>Access-Control-Allow-Origin: *
  Access-Control-Allow-Methods: POST, GET
  </code></pre>
  
  <p>I <strong>do</strong> get the response data that I want. But I can't get full HTTP header response.</p>
  
  <p>With PHP, I set the following before sending the text response. So I assume that I should get it with getAllResponseHeaders(). </p>
  
  <pre><code>header('Expires: 0');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('My-Own-Test: nodatahere');
  </code></pre>
  
  <p>But here's what I got.</p>
  
  <pre><code>Content-Type: text/plain; charset=x-user-defined
  Cache-Control: must-revalidate, post-check=0, pre-check=0
  Expires: 0
  </code></pre>
  
  <p>It's missing the <code>My-Own-Test</code>. Just for reference sake, here's my Javascript:</p>
  
  <pre><code>var formData = new FormData();
  formData.append('username', 'my_username');
  formData.append('book_id', 'test password');
  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'https://mydomain.com/proc.php', true);
  xhr.overrideMimeType("text/plain; charset=x-user-defined");
  xhr.onload = function(e) { 
      console.log(this.getAllResponseHeaders());
  };
  xhr.send(formData);
  </code></pre>
  
  <p>I even tried it with jQuery... same result.</p>
  
  <pre><code>var data_to_send = {
      username: 'my_username',
      password: 'test_password'
  };
  var ajaxObj;
  ajaxObj = $.ajax({
      url: "https://mydomain.com/proc.php",
      data: data_to_send,
      type: "POST", 
      beforeSend: function ( xhr ) {
          xhr.overrideMimeType("text/plain; charset=x-user-defined");
      }
  })
  .done(function ( data ) {
      console.log( ajaxObj.getAllResponseHeaders()  );
  });
  </code></pre>
  
  <p>Still... no luck.</p>
  
  <p>But if I go through Firebug or Chrome's Developer Tool, I can see that those tools do return full HTTP header information, including <code>Content-Length</code>, <code>Content-Encoding</code>, <code>Vary</code>, <code>X-Powered-By</code>, <code>Set-Cookie</code>, <code>Server</code>, and of course <code>My-Own-Test</code>.</p>