Working with the AJAX Toolkit
Most JavaScript that you add to Visualforce pages, buttons, or links has three sections: first, connecting to the AJAX Toolkit, next, embedding the API methods in JavaScript, and finally, processing the results. This section explains each of these steps.
-
The first portion of any JavaScript code that uses the AJAX Toolkit must make the toolkit available to the JavaScript code. The syntax for this is different depending on whether you are embedding JavaScript in a Visualforce page, or a button or link.