title: XMLHttpRequest cannot load URL. Origin not allowed by Access-Control-Allow-Origin
body: <p>I want to make a small website that uses xml data from another domain. (Weather data from Weather Underground: www.wunderground.com). I am using just html and javascript, and writing it all in Visual Studio Express 2012 for Web.</p>
  
  <p>I make and send the xml request as follows:</p>
  
  <pre><code>url = "http://api.wunderground.com/api/3c6e3d838e217361/geolookup/conditions/forecast/q/51.11999893,-114.01999664.xml";
  
  xmlhttp = new XMLHttpRequest();
  xmlhttp.open("GET", url, false);
  xmlhttp.send();
  xmlDoc = xmlhttp.responseXML;
  </code></pre>
  
  <p>The problem is that I get the following error in the Google Chrome (version 29.0.1547.66) developer console:</p>
  
  <pre><code>XMLHttpRequest cannot load http://api.wunderground.com/api/3c6e3d838e217361/geolookup/conditions/forecast/q/51.11999893,-114.01999664.xml. Origin http://localhost:49933 is not allowed by Access-Control-Allow-Origin. 
  </code></pre>
  
  <p>Or this on Internet Explorer (version 10.0.8) console:</p>
  
  <pre><code>SEC7118: XMLHttpRequest for http://api.wunderground.com/api/3c6e3d838e217361/geolookup/conditions/forecast/q/51.11999893,-114.01999664.xml required Cross Origin Resource Sharing (CORS). 
  </code></pre>
  
  <p>As I understand it, CORS (<a href="http://enable-cors.org/" rel="nofollow noreferrer">http://enable-cors.org/</a>) needs effort by both the client and the server to work. I want to assume that the Weather Underground API knows what it is doing and has enabled things appropriately, such as setting the response header to include 'Access-Control-Allow-Origin: *', and I know that I get the same problems when I try the same code using another API provider (World Weather Online). So I think this is something I should be able to fix in my client code. 
  Another SO answer where the suggestion is to fix the server-side header:
  <a href="https://stackoverflow.com/questions/14728418/cors-with-xmlhttprequest">CORS with XMLHttpRequest</a></p>
  
  <p>I have tried to find answers, but don't understand articles such as:
  <a href="http://dev.opera.com/articles/view/dom-access-control-using-cross-origin-resource-sharing/" rel="nofollow noreferrer">http://dev.opera.com/articles/view/dom-access-control-using-cross-origin-resource-sharing/</a>
  <a href="http://saltybeagle.com/2009/09/cross-origin-resource-sharing-demo/" rel="nofollow noreferrer">http://saltybeagle.com/2009/09/cross-origin-resource-sharing-demo/</a></p>