谁能帮我找到正确的方法去做CORS。我搞错了
XMLHttpRequest无法加载/gateway.com。请求的资源上没有“访问-控制-允许-原产地”标题。因此,“http://localhost:7089”源是不允许访问的
通过引用以前与CORS相关的文章来创建下面的代码。Java脚本代码如下:
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
function CallWS(){
var request = createCORSRequest("POST","https://**************/gateway.com");
if (request){
request.onload = function(){
var res = request.responseText;
alert(res);
};
request.send();
}发布于 2015-07-03 12:42:52
当您正在尝试进行CORS调用时,您需要在HTTP服务器上启用CORS。当您请求初始页面时,服务器应该使用页面和允许访问源头这里进行响应,您将找到更好的彻底解释
https://stackoverflow.com/questions/31206710
复制相似问题