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

ajax login



I'm a newbie to salesforce have a little experience with javascript. I wanted to create an html with javascript to access the database from my salesforce account using the code below that i got from ajax synchronous example. I'm debugging using firefox error console and firebug. and after clicking the button it says "err.faultcode is undefined".

Can anyone help me please? 






<script language="javascript" type="text/javascript" src=""></script>
<script language="javascript" type="text/javascript" src="/soap/ajax/17.0/connection.js"></script>
<script language="javascript" type="text/javascript">
    function xtest(){
    sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}");

    function test(){
            var username = "";
            var password = "8KoJeKjRBYNLMxxUBUL1EzFky6NoQ4KQT7Wh8qb5r5aJ1";
            var result = sforce.connection.login( username, password );
                log("logged in with session id " + result.sessionId);
        }catch(error) {
            if (error.faultcode.indexOf("INVALID_LOGIN") != -1) {
                log("check your username and passwd, invalid login");
            } else {
    function log(message) {

    <input type="button" onclick="test()" value="test" />




-  Thanks in advance.



You should not use the beta version of the Ajax toolkit, it has been deprecated.

Please take a look at the documentation here :

You will find useful sample code


Hi Artabus,


Thanks for the quick reply. I tried removing the beta version but this is the error that i keep receiving.."

An error has occurred:

ReferenceError: requireScript is not defined". It seems it can't see the javascript connection file. I also want to clear too that I'm trying these in local machine using XAMPP.


Any thoughts ..please