function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bhavdip Gadhiya 7Bhavdip Gadhiya 7 

how to call apex method using jquery ?

page : 

<apex:page controller="accountlist">
    <apex:stylesheet value="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"/>
    <apex:includeScript value="//code.jquery.com/jquery-1.10.2.js"/>
    <apex:includeScript value="//code.jquery.com/ui/1.11.2/jquery-ui.js"/>
    <apex:includeScript value="{!URLFOR($Resource.Jquery, '/js/jquery-1.7.2.min.js')}"  />
    
    <script>
        j$ = jQuery.noConflict();
           j$(document).ready(function (){
            j$("#select1").click(function() {
              val xyz = document.getElementById("{!$Component.theForm.thePageBlock.thePageBlocksection.theTable}").val(); 
            alert(xyz);
               });
            });
     
    </script>

<body>

<apex:form id="theForm" > 
<apex:pageblock  id="thePageBlock" >
    <apex:pageblocksection  id="thePageBlocksection" >
 
        <apex:pageblocktable value ="{!listAccount}" var="acc" id="theTable" >
            <apex:column headerValue="Account Name"
               value="{!acc.Name}" id="select1">
             </apex:column> 
        </apex:pageblocktable>
        
   <apex:dataList value="{!accountDetail}" var="acc" id="accountdetails1" rendered="(!listaccount.size!=0)" >
       <apex:outputText value="{!acc.name}" />
       <apex:outputText value="{!acc.phone}"/> 
         </apex:dataList>
       
    </apex:pageblocksection>
    </apex:pageblock>
    </apex:form>
    
</body>    
</apex:page>

apex class 

public class accountList{

    public String getA() {
        return null;
    }


    public accountList() {
                 listAccount = [select id,name,phone from account limit 10];
          listContact = [select name from contact limit 10];
    }

    public list<account> listAccount{get;set;}
    public list<contact> listContact{get; set;}
    public list<account> accountDetail{get;set;}

    public pagereference list1()
    {
        listAccount = [select name,phone from account limit 10];
        listContact = [select name from contact limit 10];
    return null;
    } 
    @RemoteAction
      public static void fetchAccount(string id1)
    {
          system.debug('id1' + id1); 
       
        list<account> accountDetail = [select name,phone from account where name=:id1];
    
    }
    
}
Bhavdip Gadhiya 7Bhavdip Gadhiya 7
I want return value of which selected in jquery from pageblock table and give to apex class method fetchaccount(value) 
VT878VT878
If you use @Remote Action, the method and the variable in the controller must be static. 

For me, the most simple way is the Remote Object and not Remote Action. You can find this topic on Visualforce Developer Guide.