현재 Marketo의 API에서 데이터를 검색하고 전송하려고합니다. 문제는 내 웹 플랫폼이 Salesforce Community입니다. 이 웹 도구를 올바르게 이해하면 순수한 자바 스크립트 이외의 것을 사용할 수 없습니다.자바 스크립트만을 사용하여 Marketo API를 호출하십시오.
나는 이런 CORS 요청 구축했습니다 : http://www.html5rocks.com/en/tutorials/cors/의 도움으로
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 makeCorsRequest() {
var url = document.getElementById('url').value;
var xhr = createCORSRequest('GET', url);
if (!xhr) {
alert('CORS not supported');
return;
}
xhr.onload = function() {
var text = xhr.responseText;
alert('Response from CORS request to ' + url + 'is : ' + text);
};
xhr.onerror = function() {
alert('Woops, there was an error making the request.');
};
xhr.send();
}
을하지만,이 오류가 돌아 오기 때문에 서버는 요청을 수락하지 않는 것 :
를 "없음 'Access-Control-Allow-Origin'헤더가 요청 된 리소스에 존재합니다. 따라서 'http://testurl ...'의 원본은 액세스 할 수 없습니다. "
Marketo의 API가 CORS 요청을 수락하면 누구에게 알 수 있습니까? 아니면이 문제를 해결하는 데 도움이 될만한 아이디어가 있습니까? 고맙습니다.