AJAX Invocation of Controller Action Methods | DEV-501 Exam Prep

Using apex:actionFunction for JavaScript Invocation | Salesforce Exam Preparation

Question

A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request.

An <apex:actionFunction> component must be a child of an <apex:form> component.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

The correct answer to this question is B. apex:actionFunction.

An apex:actionFunction component is used to invoke controller action methods directly from JavaScript code using an AJAX request. This component is typically used in Visualforce pages where you need to perform some action on the server side without a page refresh.

The syntax for the apex:actionFunction component is as follows:

<apex:actionFunction name="functionName" action="{!controllerMethodName}" />

The "name" attribute specifies the name of the JavaScript function that will be used to invoke the server-side controller method. The "action" attribute specifies the name of the controller method that will be invoked.

It's important to note that an apex:actionFunction component must be a child of an apex:form component. This is because the component uses the same form data that is submitted when the form is submitted.

Option A, apex:messages, is incorrect because it is used to display messages that are generated by the controller or validation rules.

Option C, apex:insert, is also incorrect because it is not a valid Visualforce component.

Option D, apex:outputField, is used to display the value of a field on a record. It does not have anything to do with invoking controller action methods directly from JavaScript code using an AJAX request.