我创建了简单的google扩展并获得JSON数据,但是这个错误是生成的
dashboard.html:1 Access to XMLHttpRequest at 'https://humane-like-developer-edition.ap4.force.com/services/apexrest/SessionHuman' from origin 'chrome-extension://dgbedclgdamcknolmpacbbigocadoiko' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
这是我的密码
var HttpClient=function()
{
this.get=function(aUrl,aCallback)
{
var anHttpRequest=new XMLHttpRequest();
anHttpRequest.onreadystatechange=function()
{
if(anHttpRequest.readyState==4 && anHttpRequest.status==200)
{
aCallback(anHttpRequest.responseText);
}
}
anHttpRequest.open("GET",aUrl,true);
anHttpRequest.send(null);
}
}
var theurl='https://humane-like-developer-edition.ap4.force.com/services/apexrest/SessionHuman';
var client=new HttpClient();
client.get(theurl,function(response){
alert(response);发布于 2018-10-29 09:23:48
没有“访问-控制-允许-原产地”标题存在于所请求的资源上.
请求的资源必须响应与您的Access-Control-Allowed-Origin请求头匹配的Origin标头。
如果它是一个公共API,您应该使用*进行响应。注意:如果不是*,则协议是响应的类型,不允许多个值为,不允许使用,也不允许通配符。
https://stackoverflow.com/questions/53041336
复制相似问题