Newer Version Available

This content describes an older version of this product. View Latest

Sample Visualforce Page Using the AJAX Toolkit

This example demonstrates using the AJAX Toolkit in a Visualforce page.

To add JavaScript to an Visualforce page, use the following procedure:

  1. Create the Visualforce page. For more information on this, see the Visualforce Developer's Guide.
  2. 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:

output of scontrol, list of Ids, names, and value for industry

An easier way to create this page is by using an Apex controller. However, the sample is intended to show basic functionality with the AJAX Toolkit that contains API calls and processes Salesforce data.

Note