Get Current Page Parameter Using Javascript
In This Blog We Learn About Apex Javascript Remoting
What is Javascript Remoting?
 Apex Javascript Remoting In VisualForce Page is a tool that front-end developers can use to make an AJAX request from a Visualforce page directly to an Apex controller. JavaScript Remoting allows you to run asynchronous actions by decoupling the page from the controller and to perform tasks on the page without having to reload the entire page.

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

Share Post

By Himanshu Rana

My Name is Himanshu Rana, 23 Years young, born and grow up in Ghaziabad, India. A High Spirited Salesforce Admin, Developer and a Blogger. I currently work at Wakencode Technologies,

Leave a Reply

Your email address will not be published. Required fields are marked *