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
unikevinunikevin 

ajax beta1 error when login using "http://..."

hi,

I'm using ajax beta1 and find it works well in S-control.

But when I put it on my server and using the address eg "http://localhost:8080/test.html" , A "no permission error" occurred.

The code I using:

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");

if (sforceClient.getSessionId().indexOf("!API_Session_ID") != -1)
{    
   var lr = sforceClient.Login("admin@xxx.com", "xxxx"); // error occurred here , no permission.
}
else {
...
}

The strange thing is : if I use "file:///c:/tomcat/.../test.html" to access the file, it works properly well!

so, why can't I use my own hard code account infomation to login salesforce when using "http://" prefix?

unikevinunikevin
I solved it!

First login salesforce in a local jsp file, like login.jsp , and replaced

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");

with

sforceClient.init(GetCookieValue('sid',base64decode(getCookie('sinfo'))), GetCookieValue('endpoint',base64decode(getCookie('sinfo'))));

in my ajax html file,then it works fine!

So, does the IE security setting cause the permission problem?
DevAngelDevAngel
When you host it from your own server you are now in a cross domain situation by making a login call to salesforce's web service. This doesn't happen when you run it from the file system because it's a different security zone.