title: PHP Cross-Origin-Request blocked
body: <p>I have a PHP-script which takes a POST-variable from a request, does something with it (in this case it's an memcached request for the specific key) and sends it back via JSON. </p>
  
  <p>The complicated part is that I don't host this script on the same Server as I do with the script doing the request. So I tried to use CORS. My browser tells me that I haven't set the Access-Control-Allow-Origin-Header, but I did as you can see. So I guess that I set it wrong. But I haven't really dealt with headers in PHP so I have really no clue what do do. I already searched (also on Stackoverflow) but all I found is that I have to set this header, what I did...</p>
  
  <p>Of ourse the memcache-part isn't really interesting for solving the problem but I thought it would be better to let you guys take a look at the complete code, so here you go:</p>
  
  <pre><code>&lt;?php
  header("Access-Control-Allow-Origin: * ");
  $key = $_POST["key"];
  $json = "";
  if($key != "")
  {
  
      define('MEMCACHED_HOST', '127.0.0.1');
      define('MEMCACHED_PORT', '11211');
      $memcache = new Memcache;
      $memcache-&gt;connect(MEMCACHED_HOST, MEMCACHED_PORT);
  
      $value = memcache-&gt;get($key);
  
      $json_array = array("status" =&gt; "done" , "key" =&gt; $key, "value" =&gt; $value);
      $json = json_encode($json_array);
  }
  else
  {
      $json_array = array("status" =&gt; "empty");
      $json = json_encode($json_array);
  
  }
  echo $json;
  ?&gt;
  </code></pre>