title: XMLHttpRequest cannot load Origin is not allowed by Access-Control-Allow-Origin
body: <p>I am trying to get an http:// javascript file via xhr but I am running into the error mentioned above.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>function getXHR() {
      var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') &gt; -1;
  
      if (is_chrome) {
      var xhr = new XMLHttpRequest();
      xhr.open("GET", "http://api.widgets.org/widget/1.1.2/widget_api.js?autoCreate=false&amp;log=true", true);
      xhr.onreadystatechange = function() {
      if (xhr.readyState == 4) {
          var s = document.createElement('script');
          s.textContent = xhr.responseText;
          (document.head||document.documentElement).appendChild(s);
          s.parentNode.removeChild(s);
          }
      }
      xhr.send();
      }
  }
  </code></pre>
  
  <p>This is only for Chrome because I would like to use the script in https:// but Chrome automatically blocks anything from http://. The server from which I am getting the script does not run https:// and I NEED the script/have multiple scripts I'd rather not all copy down into a data file.</p>
  
  <p>The error I'm running into:</p>
  
  <pre><code>XMLHttpRequest cannot load http://api.widgets.org/widget/1.1.2/widget_api.js?autoCreate=false&amp;log=true. Origin https://mysite.com is not allowed by Access-Control-Allow-Origin.
  </code></pre>