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 a Visualforce page, use this procedure:

  1. Create the Visualforce page. For more information, 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 you created and navigated to the Visualforce page, you see text similar to this image:

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

You can also use an Apex controller to create the Visualforce page. However, this sample is about basic functionality with the AJAX Toolkit that contains API calls and processes Salesforce data.

Note