How can you call a controller method from javascript?



How can you call a controller method from javascript?..

Answer / Prakash Narayan Mishra

To call a controller method from JavaScript in Salesforce, use the $A.getCallback() function along with $A.enqueueAction(). Here's an example:n```javascriptn$A.getCallback(function(){{n var action = $A.createAction(actionType);n action.setParams({param1: 'value1'});n $A.enqueueAction(action).then(function(response) {n // Handle response from controller method here.n });n}});n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Salesforce Interview Questions

What type of workflow alerts are there?

1 Answers  


What is the difference between the normal “insert” operation and “database.insert” operation ? Which is preferred over the other and why ?

1 Answers  


What is transient keyword in salesforce?

1 Answers  


Can a dependent field be a controlling field as well in salesforce ?

1 Answers  


How can you create object relations in salesforce?

1 Answers  


How many records can we fetch using one soql query?

1 Answers  


What is an Auto-Response Rule?

1 Answers  


If a user does not have access to a specific record type, will they be able to see the records that have that record type? : salesforce sharing and security

1 Answers  


What is lazy loading in salesforce?

1 Answers  


Explain what is Audit trail?

1 Answers  


What is manual sharing?

1 Answers  


Compare Jump Start Wizard vs. Standard Wizard?

1 Answers  


Categories