Use JavaScript remoting in Visualforce to call methods in Apex controllers from JavaScript. Create pages with complex, dynamic behavior that isn’t possible with the standard Visualforce AJAX components.
@RemoteAction global static String getItemId(String objectName) { ... }
[namespace.]controller.method( [parameters...,] callbackFunction, [configuration] );
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. |
For more information, see “JavaScript Remoting for Apex Controllers” in the Visualforce Developer's Guide.