No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
The AJAX Toolkit
- The AJAX Toolkit is available for any organization that has API access.
- The AJAX Toolkit supports Microsoft® Internet Explorer® versions 7, 8, 9, 10, and 11 with the latest Microsoft hot fixes applied, and Mozilla® Firefox®, most recent stable version.
- The AJAX Toolkit is based on the partner WSDL. Because there is no type checking in JavaScript, the type information available in the enterprise WSDL is not needed.
- You can execute any call in the API, and access any API object that you normally have access to.
- You can issue asynchronous calls, and use callback functions to handle the results. For more information, see API Calls and the AJAX Toolkit.
- You can use header options with a different syntax than in the API. For more information, see Using SOAP Header Options with the AJAX Toolkit.
- You can handle errors with the AJAX Toolkit. For more information, see Error Handling with the AJAX Toolkit.
- The AJAX Toolkit supports relationship queries. See Synchronous Examples for examples of relationship queries.
This document explains how to use the AJAX Toolkit in JavaScript to embed API calls and processes, such as within a Visualforce page.
When to Use the AJAX Toolkit
Because information is delivered via a browser, AJAX works best with relatively small amounts of data (up to 200 records, approximately six fields with 50 characters of data each). The larger the data set returned, the more time it will take to construct and deconstruct a SOAP message, and as the size of an individual record gets larger, the impact on performance becomes greater. Also, as more HTML nodes are created from the data, the potential for poor performance increases. Because browsers are not efficient, careful consideration needs to be given to browser memory management if you intend to display a large amount of data.
- Display or modify a single record.
- Display two or three fields from many records.
- Perform one or more simple calculations, then update a record.
- Update more than 200 records.
- Update records that are unusually large. For example, what happens if the user clicks the browser stop button?
- Recalculate a complex value for more than 200 records.
An example of inappropriate usage is providing a sortable grid of many records. This would require too much processing time, and browser rendering would be too slow.
AJAX Toolkit Support Policy
The current release of the AJAX Toolkit is the only version that receives bug fixes and enhancements. When a new version is released, the previous version continues to be available, but is not supported.
Other Resources
- Eclipse plug-in: Force.com IDE
- Message boards: Developer Force
AJAX Typographical Conventions
| Convention | Description |
|---|---|
| <script src="/soap/ajax/30.0/connection.js" type="text/javascript"></script> | In an example, Courier font indicates items that you should type the information as shown. This includes sample code, literals, methods, calls, functions, and events from a variety of languages. |
| sforce.connection.header_option_name="value"; | In an example or syntax statement, italics represent variables. You supply the actual value. |
Sample Visualforce Page Using the AJAX Toolkit
To add JavaScript to an Visualforce page, use the following procedure:
- Create the Visualforce page. For more information on this, see the Visualforce Developer's Guide.
- Cut and paste the following sample code into your Visualforce page.
The JavaScript code queries your organization and returns every account ID, account name, and industry type, if any:
After creating and navigating to the aboveVisualforce page, you should see text similar to this image:
