+ Start a Discussion
Chidanand MChidanand M 

actionFunction and remote action

Hey Guys,
Can anyone explain me when do we use actionFunction over remote action and vice-versa with an example Code.
Vasani ParthVasani Parth
Chidu - @RemoteAction and apex:actionFunction are essentially polar opposites in terms of functionality, even though they both offer JavaScript functionality.

@RemoteAction is an Apex annotation used to mark a method as being available for javascript remoting. This allows you to call the method from javascript yourself and retrieve the result as a javascript object for manipulation, as per the example in the documentation. They are static and global, and hence don't have access to your current controller variables and methods.

<apex:actionFunction> is a Visualforce tag which has been around longer than remoting and allows you to invoke a controller action from javascript; it doesn't let you get retrieve data but you can rerender the page or a specific section of the page to update it with new values from the controller instance.

Please mark this as the best answer if this helps