JavaScript remoting allows a controller method to be invoked directly from JavaScript with no Visualforce components necessary. Instead, you annotate the controller method with @RemoteAction
and write a small amount of JavaScript to call it.
Although similar in function to JavaScript remoting, the actionFunction
Visualforce component differs in some significant ways. The actionFunction
component is designed for use in a Visualforce page with other native Visualforce components. Like most Visualforce components, it uses a form to create a stateful interaction between the controller and the page. This is not the case with remoting, which makes it a bit more responsive as a result. Remoting is also asynchronous, while the actionFunction
component is synchronous.
JavaScript remoting is particularly helpful in the development of single-page applications on Force.com. With JavaScript remoting, the focus of the Force.com platform shifts to the back end. It serves the raw resources to power the user interface, both static files and dynamic data via controller method invocations. Once loaded, the user interface is rendered entirely in JavaScript within the browser, with callouts made to the Apex controller as needed for its data services.
18.191.14.196