-1

ERROR XMLHttpRequest cannot load - No 'Access-Control-Allow-Origin' header is present on the requested resource.

//XMLHttpRequest

var xhr = new XMLHttpRequest();
if (!('withCredentials' in xhr)) { 
alert('Browser does not support CORS.'); 
return; 
} 
xhr.onerror = function() { 
alert('There was an error.'); 
}; 
xhr.onload = function() {"done"}
xhr.open("GET", "http://indicadoreseconomicos.bccr.fi.cr/indicadoreseconomicos/WebServices/wsIndicadoresEconomicos.asmx/ObtenerIndicadoresEconomicos?tcIndicador=318&tcFechaInicio=01/03/2014&tcFechaFinal=01/01/2016&tcNombre=A&tnSubNiveles=N",true);
xhr.send(null);
console.log("loading >>>")
</script>
</head>
<body>
</body>
</html>
user2665860
  • 31
  • 1
  • 1
  • https://stackoverflow.com/questions/3595515/xmlhttprequest-error-origin-null-is-not-allowed-by-access-control-allow-origin?rq=1 and http://stackoverflow.com/questions/5008944/how-to-add-an-access-control-allow-origin-header – MonkeyZeus Jun 03 '14 at 17:31
  • 1
    Stackoverflow is a **Q** and A site. You forgot about `Q`. – spender Jun 03 '14 at 17:31

1 Answers1

1

In the spirit of your question, the answer is:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

Exactly as described in the error.

This means that at the server, you need to add an Access-Control-Allow-Origin header to the response that indicates to the browser that the current domain is permitted to download from this host. If the server in question is out of your control, then you're out of luck and you'll need to download the content server-side.

spender
  • 117,338
  • 33
  • 229
  • 351