title: 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I'm having a problem related to cors, I can't get rid of famous </p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load external domain.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'mydomain.com' is therefore not allowed access</p>
  </blockquote>
  
  <p>What I tried:</p>
  
  <ul>
  <li><a href="http://www.html5rocks.com/en/tutorials/cors/" rel="nofollow">http://www.html5rocks.com/en/tutorials/cors/</a>  - End-to-End Example , still doesnt work , getting the same error.</li>
  <li><a href="https://www.sencha.com/forum/showthread.php?299915-How-to-make-an-ajax-request-cross-origin-CORS" rel="nofollow">https://www.sencha.com/forum/showthread.php?299915-How-to-make-an-ajax-request-cross-origin-CORS</a></li>
  <li>other various examples </li>
  </ul>
  
  
  
  <pre><code>// Create the XHR object.
  function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    if ("withCredentials" in xhr) {
      // XHR for Chrome/Firefox/Opera/Safari.
      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;
  }
  
  // Helper method to parse the title tag from the response.
  function getTitle(text) {
    return text.match('&lt;title&gt;(.*)?&lt;/title&gt;')[1];
  }
  
  // Make the actual CORS request.
  function makeCorsRequest() {
    // All HTML5 Rocks properties support CORS.
    var url = 'http://updates.html5rocks.com';
  
    var xhr = createCORSRequest('GET', url);
    if (!xhr) {
      alert('CORS not supported');
      return;
    }
  
    // Response handlers.
    xhr.onload = function() {
      var text = xhr.responseText;
      var title = getTitle(text);
      alert('Response from CORS request to ' + url + ': ' + title);
    };
  
    xhr.onerror = function() {
      alert('Woops, there was an error making the request.');
    };
  
    xhr.send();
  }
  </code></pre>
  
  <p>Example above only works in launching static html when I upload it to main domain I'm getting error which I mentioned above.</p>