+ Start a Discussion

Action function vs Command button

Can somebody please explain me what is the difference between calling a method in apex class from command button and calling an apex class method from javascript

Thanks in Advance...
There's no difference from the Apex side. The difference is all in the front end markup. A commandbutton allows you to call an apex action method when the button is pressed, but under no other circumstances. An actionfunction allows you to execute an apex action method via JavaScript and can thus be used in a number of different scenarios. You could emulate a command button via a regular HTML button with an onclick handler that invokes an actionfunction, but the commandbutton standard component means you don't have to!