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
John T.John T. 

Use Jquery to login to salesforce

Hi Guys,

 

I have this dilemma here for days, I can't manage to login to salesforce using Jquery.What I needed is after I login, I will parse the response and get the sessionId. This error occurs after I try to login:

 

XMLHttpRequest cannot load https://login.salesforce.com/services/oauth2/token. Origin https://c.ap1.visual.force.com is not allowed by Access-Control-Allow-Origin.

 

These my code:

 

$j.ajax({

type: 'POST',

  url: 'https://login.salesforce.com/services/oauth2/token',

      data: 'grant_type=password&client_id='+ clientId + '&client_secret=' +secretKey + '&username=' +username +'&password=' + password,

 success: function(data){

    response = data;

}});

 

Your help would much be appreciated.

 

Cheers,

 

nkimnkim

I'm having the exact same issue.  :-(