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
Elad Kaplan 3Elad Kaplan 3 

Login to salesforce using connection.js

Does anybody has a working example that uses the connection.login.js ?

I'm trying to connect to salesforce from an exterior website using javascript and getting an Error.

Here is My code:

<!DOCTYPE HTML>
<HTML>
<HEAD>

<script src="https://na6.salesforce.com/soap/ajax/30.0/connection.js" ></script>

<script type="text/javascript" >

function logincall()
{

    try{
   
   
    var usrname = document.getElementById('userid').value;
    var passwrd = document.getElementById('passid').value;

    if(usrname == null || usrname == '' || passwrd == null || passwrd == '')
    {
        alert('Please enter Username AND Password');
        return;
    }
   
    var result = sforce.connection.login(usrname, passwrd);

    alert("Logged in with session id " + result.sessionId);
    }
    catch(error)
    {
        alert(error);
       
       
    }

}
</script>

</HEAD>

<BODY>

To test logging into a Salesforce Instance using the connection.js "login" call

<table>
        <tr>
            <td>Username</td>
            <td><input type="text" id="userid" value="" /></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" id="passid" value="" /></td>
        </tr>

</table>

    <input type="button" value="Login" onclick="logincall();" />

</BODY>

</HTML>


I'm getting an Error :  The requested url services/Soap/u/30.0 was not found on this server


Any idea anyone?

ShashForceShashForce
This should help: http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax_connecting.htm

I think you are missing this line:

{!requireScript("/soap/ajax/30.0/connection.js")}
Ravikant kediaRavikant kedia
Hi Elad Kaplan 3,
                              How to solve above problem in javascript code outside salesforce envrionment please give me some idea or code to solve above problem because i am facing same problem in creating chrome extension .
Thanks in Advance.

 
Ravi NarayananRavi Narayanan
anyone achieved the above task of connecting html to salesforcE?
Koustubh KulkarniKoustubh Kulkarni
Anyone know how to login through HTML page to salesforce community?
 
John smith 391John smith 391
Anyone know how to login salesforce using javascript not visual force
 
Honza KoubaHonza Kouba
I would also like to know the possibilities. Thank you