title: Javascript: " No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. "
body: <p>I need to write a web page that can get some information I need with JavaScript.
  The sever is a bamboo sever and I am trying to utilize the REST API of theirs in my JavaScript.
  <a href="https://developer.atlassian.com/display/BAMBOODEV/REST+APIs" rel="nofollow">https://developer.atlassian.com/display/BAMBOODEV/REST+APIs</a></p>
  
  <p>The weird part is that I can perform all the requests by typing the link in the browser, or with curl command in termanal. It also works via a python script. I can receive the data with all the methods mentioned in the paragraph. It's just that when I go to JavaScript, it doesn't work anymore.</p>
  
  <p>I have been following the information in the below link for making the CORS request.
  <a href="http://www.codeproject.com/Articles/185506/AJAX-Cross-Origin-HTTP-request" rel="nofollow">http://www.codeproject.com/Articles/185506/AJAX-Cross-Origin-HTTP-request</a></p>
  
  <p>Attached below is my code. I was wondering if I have missed something.</p>
  
  <pre><code>&lt;!doctype html&gt;
  
  &lt;html&gt;
      &lt;head&gt;  
      &lt;meta http-equiv="Access-Control-Allow-Origin" content="*"&gt;
      &lt;meta content="text/html;charset=utf-8" http-equiv="Content-Type"&gt;
      &lt;meta content="utf-8" http-equiv="encoding"&gt;
          &lt;script src="jquery-1.11.1.js"&gt;&lt;/script&gt;
      &lt;script src="crypto-js.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
          function showResponse (response) {
              RESPONSE = response;
              if (this &amp;&amp; this.url &amp;&amp; (typeof(this.url) == "string")) {
                  var anchor = jQuery("#url");
                  anchor.text(this.url.toString());
                  anchor.attr('href', this.url.toString());
              }
              jQuery("#output").text(JSON.stringify(response, null, '  '));
          }
          &lt;/script&gt;
          &lt;script type="text/javascript"&gt;
  
  
  
  
      console.log("a")
      var cor = null; // cor stands for Cross-Origin request
  
      if (window.XMLHttpRequest) {
          console.log("support xmlhttprequest");
          cor = new XMLHttpRequest();
      }else {
          console.log("Your browser does not support Cross-Origin request!");
      }
  
  
      if("withCredentials" in cor){
          cor.open('GET', 'http://bamboo.example.com/rest/api/latest/stuff', true);
          cor.withCredentials = true;
          cor.setRequestHeader('Authorization', 'Basic encoded_stuff');
          cor.send();
      }
  
      cor.onload = function(){
          var responseText = xhr.responseText;
          console.log(responseText);
      };
  
      cor.onerror = function() {
          console.log('There was an error!');
      };
  
  
  
  
  
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;URL:&lt;a id="url"&gt;&lt;/a&gt;&lt;/div&gt;
          &lt;hr&gt;
          &lt;div&gt;
              &lt;pre id="output"&gt;
                  &lt;!-- content will appear here --&gt;
              &lt;/pre&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The chrome console shows "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."  as a result along with 401 status.</p>
  
  <p>Was wondering if I am missing with the code?</p>
  
  <p>Thank you</p>