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
Jake898Jake898 

AjaxToolkit and HTML 5 apps

I am new to salesforce product. I am developing an application using Sencha Touch. I see a lot of references using VisualForce and Apex tools to developer pages interacting with database.
 

Is it possible to use ajax toolkit from sencha touch app?

I tried to use the connection.js library, but i am not able to login and i didn't see any documentation or tutorial on how to make this happen on sencha app or just html 5 app, unless it is iOs or Android app.

i've made reference to


http://na7.salesforce.com/soap/ajax/21.0/connection.js

 


i am wondering i need to add the token to the password

 

Can someone provide me with an example for sencha or html 5

 

Thanks

OksmanOksman

Jake,

 

Check out the HTML5 example in the Mobile SDK Workbook. We are using JS Remoting with JQueryMobile to create a mobile app. Since all we do is pass JSON back and forth, you can easily swap in your Sencha implementation. 

Jake898Jake898

I am having issues making a connection....do I have to supply the token every single time if I deploy to a different device?

 

Thanks

OksmanOksman

Are you running the HTML5 inside the browser or container? 

Jake898Jake898

for testing purposes i am running inside browser, i mean this sounds silly, but the code is rather simple, at least i hope it should be

 

    <script src="http://na7.salesforce.com/soap/ajax/21.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
try{
    var result = sforce.connection.login("YYYYYYYYY", "XXXXXXXXXX");
    log("logged in with session id " + result.sessionId);
  }catch(error) {
  alert(error);
    if (error.faultcode.indexOf("INVALID_LOGIN") != -1) {
      log("check your username and passwd, invalid login");
    } else {
      log(error);
    }
  }
  </script>

OksmanOksman

In the iOS SDK, check out the Contact Explorer hybrid app. It shouls how to use tkforce.js and preserve the tokens.

Jake898Jake898

so the above approach is incorrect? i am missing another js file?

Jake898Jake898

Thanks for the help, I just checked out the index.html file of the ContactExplorer project

 

https://github.com/forcedotcom/SalesforceMobileSDK-iOS/blob/master/hybrid/SampleApps/ContactExplorer/ContactExplorer/www/index.html

 

I noticed two js files, I don't know if I need them. 

 

SalesforceOAuthPlugin.js
forcetk.js

 

I am just trying to connect to database and do simple querying, is it possible to do with just pure javascript in HTML 5 or does it have to be using visualforce pages or hybrid. I know you achieved it using js remoting. but it shouldn't be this difficult to connect to db and query the api, right???

JaggyJaggy

Jake,

 

According to me, Ajax Toolkit is only works inside VF pages. Are you running your JS code within a VF page? If not then I guess you have to use oauth for login. And if you are running your code within a VF page then you can use JS remoting or Ajax Toolkit.

 

Note:- When using JS remoting or Ajax Toolkit, code in such way that when you create a managed package out of your code then your this javascript code should not get broken.