function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Riyaz KhanRiyaz Khan 

CORS header 'Access-Control-Allow-Origin' missing error

I have tried to get json response from public salesforce API 'https://na1.salesforce.com/services/data/'. When I use HTTP/REST tool its working fine and return string as json. But when I am tring to call public API through jQuery AJAX request and giving following error:

"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://na1.salesforce.com/services/data/. (Reason: CORS header 'Access-Control-Allow-Origin' missing)."

Please provide the solution how can I call API from simple HTML page using AJAX request.
scottbcovertscottbcovert
Hi Riyaz,

In Spring '15 Salesforce began offering CORS whitelisting. You can specify the domain that is serving your script as a trusted resource through the UI by following the instructions here: https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/extend_code_cors.htm

Best,
Scott