The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via Javascript. This process is often referred to as
Javascript remoting.
To use JavaScript remoting in a Visualforce page, you add the request as a JavaScript invocation, which
has the following form:
[<namespace>.]<controller>.<method>([params...,] <callbackFunction>(result, event) {
// callback function logic
}, {escape:true});
where
namespace is 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 is the name of
your Apex controller.
method is the name of the Apex method you're calling.
params is the comma-separated
list of parameters that your method takes.
callbackFunction is the name
of the JavaScript function that will handle the response from the
controller. callbackFunction receives
the status of the method call and the result as parameters.
escape specifies whether
your Apex method's response should be escaped (by default, true) or not (false).
In your controller, your Apex method declaration is preceded with the @RemoteAction annotation like this:
Your method can take Apex primitives, collections, typed and generic sObjects, and user-defined Apex classes as arguments. Generic sObjects must have an ID or sobjectType
value to identify actual type. Your method can return Apex primitives, sObjects, collections, user-defined Apex classes and enums, SaveResult, UpsertResult, DeleteResult, SelectOption, or PageReference.
For more information, see JavaScript Remoting for Apex Controllers in the Visualforce Developer's Guide.