Calling remote controller method with Parameters from Java Script in page

<apex:page controller="ChildRemoteController" >
    <script type="text/javascript">
        function sayHello(helloTo) {
            ChildRemoteController.sayHello(helloTo, function(result, event){
                if(event.status) {
                    document.getElementById("result").innerHTML = result;
                }
            });
        }
    </script>

    <button onclick="sayHello('Shravan');">Say Hello</button><br/>
    <div id="result">[Results]</div>
    
</apex:page>
-------------------------------------------------------------

global with sharing class ChildRemoteController {
   
    @RemoteAction
    global static String sayHello(String helloTo) {
        return 'Hello ' + helloTo + ' from the Grandparent.';
    }


}

Comments

Popular posts