You need to sign in to do that
Don't have an account?
Ashlekh
Cross Origin
Hi All,
I've created an application in which I need to use jquery and need to use REST API.
In Jquery when I am trying to hit or create a ajax request then facing below issue.
Issue -XMLHttpRequest cannot load https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+apexclass&_=1476807054409. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.ap1.visual.force.com' is therefore not allowed access.
my code is
Could you please help me on this.
-Thanks
Ashlekh Gera
I've created an application in which I need to use jquery and need to use REST API.
In Jquery when I am trying to hit or create a ajax request then facing below issue.
Issue -XMLHttpRequest cannot load https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+apexclass&_=1476807054409. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://c.ap1.visual.force.com' is therefore not allowed access.
my code is
$.ajax({ type: 'GET', url : "https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+account", crossDomain : true, async:true, 'Access-Control-Allow-Origin':'*', 'Access-Control-Allow-Methods':'GET', beforeSend: function (xhr) { xhr.setRequestHeader('crossDomain', true); xhr.setRequestHeader('Authorization', "Bearer " + accessToken); xhr.setRequestHeader('Accept', "application/json"); }, success : function(response){ console.log(response); } }); }
Could you please help me on this.
-Thanks
Ashlekh Gera
Please refer below links with the similar discussion you may get some information.
http://salesforce.stackexchange.com/questions/51193/xmlhttprequest-cannot-load-no-access-control-allow-origin-is-present
https://github.com/jsforce/jsforce/issues/139
http://stackoverflow.com/questions/9310112/why-am-i-seeing-an-origin-is-not-allowed-by-access-control-allow-origin-error
Hope this helps you!
If this helps you mark it as solved.
Thanks and Regards
Sandhya