Adding JavaScript Remoting to a Visualforce Page

To use JavaScript remoting in a Visualforce page, add the request as a JavaScript function call.
A simple JavaScript remoting invocation takes the following form.
[namespace.]controller.method(
    [parameters...,]
    callbackFunction,
    [configuration]
);
Table 1. Remote Request Elements
Element Description
namespace The namespace of the controller class. This is required if your organization has a namespace defined, or if the class comes from an installed package.
controller The name of your Apex controller.
method The name of the Apex method you’re calling.
parameters A comma-separated list of parameters that your method takes.
callbackFunction The name of the JavaScript function that will handle the response from the controller. You can also declare an anonymous function inline. callbackFunction receives the status of the method call and the result as parameters.
configuration Configures the handling of the remote call and response. Use this to change the behavior of a remoting call, such as whether or not to escape the Apex method’s response.

The remote method call executes synchronously, but it doesn’t wait for the response to return. When the response returns, the callback function handles it asynchronously. See Handling the Remote Response for details.

Previous
Next