+ Start a Discussion

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 
                     type: 'GET',
                     url : "https://ap2.salesforce.com/services/data/v37.0/query?q=select+id,name+from+account",
                     crossDomain : true,
                   beforeSend: function (xhr) {
                     xhr.setRequestHeader('crossDomain', true);
                     xhr.setRequestHeader('Authorization', "Bearer " + accessToken);
                     xhr.setRequestHeader('Accept', "application/json");

                       success : function(response){

Could you please help me on this.

Ashlekh Gera
SandhyaSandhya (Salesforce Developers)