Friday, 21 March 2014

Connecting to the AJAX Toolkit API

The first portion of any JavaScript code that uses the AJAX Toolkit must make the toolkit available to the JavaScript code.


















































  • For Visualforce pages or any source other than a custom onclick JavaScript button, specify a <script> tag that points to the toolkit file:

  <apex:page>
  <script src="../../soap/ajax/29.0/connection.js" type="text/javascript"></script>
  ...
  </apex:page>

  •   For a custom onclick JavaScript button, specify the login call to log into the API:

  {!RequireScript("/soap/ajax/29.0/connection.js")}
  sforce.connection.login("username", "password");
  ...





.
After this script executes,the toolkit is loaded and a global object, sforce.connection, is created. This object contains all of the API calls and AJAX Toolkit methods, and manages the session ID.


Quick Link to parent document: Working with the AJAX Toolkit

No comments:

Post a Comment

Thank you for visiting. Your comments are highly appreciated.