title: header('Access-Control-Allow-Origin: *'); Not allowing CORS request
body: <p>I have a PHP file which generates a JSON document.</p>
  
  <p>I've set the <code>header</code> as follows but am still getting an error.</p>
  
  <pre><code>header('Access-Control-Allow-Origin: *');
  header('Content-Type: application/json');
  </code></pre>
  
  <p>Error message:</p>
  
  <p><code>No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://mysubdomain.mydomain.com' is therefore not allowed access.</code></p>
  
  <p>I've tried explictly allowing mysubdomain.mydomain.com using</p>
  
  <pre><code>header('Access-Control-Allow-Origin: https://mysubdomain.mydomain.com');
  </code></pre>
  
  <p>But I still get the error.</p>