CORS request not working
I'm currently trying to retrieve and send data from Marketo's API. The problem is : my web platform is Salesforce Community. If I understand correctly this web tool, I'm not allowed to use anything else than pure javascript.
I've built a CORS request like this :
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();
}
With the help of http://www.html5rocks.com/en/tutorials/cors/, but the server doesn't seem to accept the request since this error comes back :
"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'testurl…' is therefore not allowed access."
Does anyone know if Marketo's API accepts CORS requests? Or maybe have an idea that would help me solve this? Thank you very much.