【发布时间】:2014-06-03 17:28:12
【问题描述】:
错误 XMLHttpRequest 无法加载 - 请求的资源上不存在“Access-Control-Allow-Origin”标头。
//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>
【问题讨论】:
-
Stackoverflow 是一个 Q 和 A 站点。你忘了
Q。
标签: javascript jquery web-services