現在、Marketo の API からデータを取得して送信しようとしています。問題は、私の Web プラットフォームが Salesforce コミュニティであることです。この Web ツールを正しく理解していれば、純粋な JavaScript 以外を使用することはできません。
次のような 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();
}
http://www.html5rocks.com/en/tutorials/cors/の助けを借りて、しかし、このエラーが戻ってくるので、サーバーはリクエストを受け入れないようです:
「要求されたリソースに 'Access-Control-Allow-Origin' ヘッダーが存在しません。したがって、Origin ' http://testurl …' へのアクセスは許可されていません。」
Marketo の API が CORS リクエストを受け入れるかどうか知っている人はいますか? それとも、これを解決するのに役立つアイデアがありますか? どうもありがとうございました。