XMLHttpRequest cannot load - No 'Access-Control-Allow-Origin' header is present on the requested resource
本问题已经有最佳答案,请猛点这里访问。
ERROR XMLHttpRequest无法加载 - 请求的资源上不存在"Access-Control-Allow-Origin"标头。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //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 >>>") </head> <body> </body> </html> |
本着您的问题的精神,答案是:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
正如错误中所描述的那样。
这意味着在服务器上,您需要向响应添加