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
Ravi NarayananRavi Narayanan 

Connection.Js + Html pages

Hello ,

I am trying to create a html basic sample page where i want to authenticate the users using connection.js. the below code works good inside salesforce org. but doesnt work when i use the code in a html page and try to establish connecion :( anyone have experience connecting html page to salesforce ? can someone please me ?
<apex:page standardController="case">
<script src="/soap/ajax/23.0/connection.js" type="text/javascript"></script>
<script type="Text/javascript">
sforce.connection.login("username", "pwdplustoken");
function setupPage()
{
var qry="Select Id, Name, Industry From Account";
var result=sforce.connection.query(qry,layoutResults);
}
function layoutResults(queryResult, source)
{
if (queryResult.size > 0)
{
var output = "";
var records = queryResult.getArray('records');
for (var i = 0; i < records.length; i++)
{
var account = records[i];
output += account.Id + " " + account.Name +" [Industry - " + account.Industry + "]<br>";
document.getElementById("out").innerHTML=output;
}
}
}
</script>
<apex:pageBlock >
<input type="button" Title="Get Accounts" Value="Click me" OnClick="setupPage()"/>
<div id="out">test</div>

</apex:pageBlock>
</apex:page>
Ravi NarayananRavi Narayanan
can someone help me with this please?
Dushyant SonwarDushyant Sonwar
Hi Ravi,

I think the problem is with your relative url "/soap/ajax/23.0/connection.js"
as you said it is working inside salesforce org.

give a full absolute url and try to use your code it will work.
Hope this helps.