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
pabzsarquillapabzsarquilla 

ajax login

hi,

 

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? 

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title></title>

<script language="javascript" type="text/javascript" src="http://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js"></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(){
        try{
            {!requireScript("/soap/ajax/17.0/connection.js")}                
            var username = "pabz.sarquilla@gmail.com";
            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 {
                log(error);
            }   
        }   
    }
   
    function log(message) {
        alert(message);
    }

</script>
</head>
<body>
    <input type="button" onclick="test()" value="test" />
</body>
</html>

 

 

 

-  Thanks in advance.

 

ArtabusArtabus

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

Please take a look at the documentation here :

http://www.salesforce.com/us/developer/docs/ajax/index.htm

You will find useful sample code

pabzsarquillapabzsarquilla

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