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
michaelforcemichaelforce 

The AJAX Toolkit and SANDBOX edition

Is it possible at this point to use the AJAX toolkit in the sandbox?  I've tried simply logging in as follows and it doesn't work... any ideas?

Code:
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script type="text/javascript">

   sforceClient.setLoginUrl('https://test.salesforce.com');

   var loginresult = sforceClient.Login("sandbox_username","sandbox_password");

   sforceClient.setUrl(loginresult.serverURL);

   alert(loginresult.sessionID);

</script>
 
 
 
milliskennymilliskenny
I haven't tried AJAX from outside SFDC, but you may have to use the server name (ie: https://tapp0.salesforce.com) instead of the main login page (https://test.salesforce.com) for the authentication.
 
I'm using AJAX inside the sandbox and it works fine, but the user is already authenticated.
 
Just an idea...Good luck