title: Setting up CORS not working
body: <p>I have the following headers set on the server </p>
  
  <pre><code>response.addHeader("Access-Control-Allow-Origin", "*");
  response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT");
  response.addHeader("Access-Control-Allow-Headers","X-Custom-Header");
  </code></pre>
  
  <p>And i want to use the    POST method to access a web service and send data to it but the problem is my setting up with the server is causing problems</p>
  
  <p>I used the following method</p>
  
  <pre><code>function createCORSRequest(method, url) {
      var xhr = new XMLHttpRequest();
      if ("withCredentials" in xhr) {
          // XHR for Chrome/Safari/Firefox.
          xhr.open(method, url, true);
      }
      else if (typeof XDomainRequest != "undefined") {
          // XDomainRequest for IE.
          xhr = new XDomainRequest();
          xhr.open(method, url);
      } else {
          // CORS not supported.
          xhr = null;
      }
      return xhr;
  }
  </code></pre>
  
  <p>and based on this object </p>
  
  <pre><code>url = "http://myurl.do";
  var xhr = createCORSRequest('POST', url);
  if (!xhr) {
      alert('CORS not supported');
      return;
  }
  var params = "name=pari123&amp;action=initaction&amp;gameId=slotreel3";
  xhr.setRequestHeader('Content-Type', 'application/text/plain'); 
  if(xhr.readyState == 4 &amp;&amp; xhr.status == 200) 
  {
      alert('Tested OK')
      xhr.send(params);
  }
  else
  {
      alert('status not 200 or xhr is not ready');
  }
  
  // Response handlers.
  xhr.onload = function() {
      var text = xhr.responseText;
      alert('Response from CORS request to ' + url + ': ' + text);
  };
  
  xhr.onerror = function() {
      alert('Woops, there was an error making the request.');
  };
  </code></pre>
  
  <p>But always it alerts a message saying 'status not 200 or xhr is not ready' i am not able to proceed any one if you know please kindly help!</p>
  
  <p>when i print the <code>xhr.readyState</code> its printing a value of 1</p>