In addition, Javascript Remoting In VisualForce Page can help alleviate view state issues while still executing in the context of the user viewing the page. JavaScript remoting is the most efficient way of calling the controller and passing data in from the page, because you can ensure that you’re passing only the data that you need each time that you make a call.
How to use Javascript remoting in Visualforce Page
Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.CONTROLLERNAME.Methodname}',param1,param2, function(result, event){ console.log(result); /*The "result" variable return data or value from your remote action method written in Apex class.*/ } );
Controller class From which we are calling method via javascript remoting:
@RemoteAction public static Object myRemoteMethod(String param1, String param2) { return param1+'-'+param2; }
Note: parameter name should be same in apex class method and vf page
Hits: 827