Skip to main content
Hi All,

I have a requirement in which I have to communicate back and forth between apex and javascript.

The initial step being in apex should then call javascript based on some condition check, that  javascript will do some processing and will then call apex and that will again call Javascript and then apex.

Can somebody suggest how to maintain the control flow ?
2 respuestas
  1. 30 jul 2021, 17:01
    Hi Chandra, 

    please follow below steps:-

    A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An component must be a child of an component.

    <apex:commandButton value="Search" onclick="check();" reRender="nPbt" />

     

    function check(){

    var user = document.getElementById('pg:frm:nPB:ip').value;

    if(user == ''){

    alert('Please Enter noise Name before Proceeding.');

    return true;

    }

    else

    noiseSearchAF();

    return true;

    }

     

    <apex:actionFunction action="{!noiseSearch}" name="noiseSearchAF" rerender="nPbt">

    if you need any assistanse, Please let me know!!

    Kindly mark my solution as the best answer if it helps you.

    Thanks

    Mukesh