RemoteAction Annotation

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.

Note
Methods with the RemoteAction annotation must be static and either global or public.
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
In your controller, your Apex method declaration is preceded with the @RemoteAction annotation like this:
@RemoteAction
global static String getItemId(String objectName) { ... }

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.

© Copyright 2000–2012 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.