我试图绕过 sop 从 marketo api 获取潜在客户详细信息。是否可以使用 CORS 或 JSONP。似乎不是,但我担心我的代码中可能存在错误。
我正在使用“第三方 Javascript”一书中的 CORS 方法大纲
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
console.log('We have credentials');
xhr.open(method, url, false);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url, false);
console.log('Domain request is undefined');
} else {
xhr = null;
console.log('null null null');
}
return xhr;
};
xhr = new createCORSRequest();
xhr.open("GET", {url}, false);
xhr.send();
目前我收到标准的肥皂错误。
我是否只需要在接收文档的域上创建一个新的 api。实际上是 Marketo rest api 的包装器。