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
hector.asp2hector.asp2 

Pass Recordset from Apex to Ajax

Hi ,

 

I want to pass a record set generated from apex controller class constructor to ajax on a vf page. I dont want to fire same query at controller and VF. How can this be achieved.

 

Thanks

Bikram...

Ispita_NavatarIspita_Navatar

What actually are you trying to achieve?

 

Anyways please refer to the enclosed code:-

 

VF Page Code

<apex:page controller="Test100Class">

 

  
  <script>
  function show()
  {
   var x=document.getElementById('{!$Component.form1.page1.textbox1}').value
   alert(x);
  }
  </script>
<apex:form id="form1" >
<apex:pageBlock title="Congratulations {!$User.FirstName}" id="page1">
<apex:inputHidden value="{!values}" id="textbox1"/>
<apex:commandButton value="Check" onclick="show()"/>
 </apex:pageBlock>
 </apex:form>
</apex:page>

 

<apex:page controller="Test100Class">    <script>  function show()  {   var x=document.getElementById('{!$Component.form1.page1.textbox1}').value   alert(x);  }  </script><apex:form id="form1" ><apex:pageBlock title="Congratulations {!$User.FirstName}" id="page1"><apex:inputHidden value="{!values}" id="textbox1"/><apex:commandButton value="Check" onclick="show()"/> </apex:pageBlock> 

</apex:form>

</apex:page>

 

Controller Code

 

 

public class Test100Class {

 

public String values{get;set;}

    public Test100Class()

      {

       for (Account a : [SELECT id, name, (SELECT lastname FROM contacts)FROM account WHERE id = :ApexPages.currentPage().getParameters().get('id')])

         {

            values = values +';'+ a.contacts;

          }

         }

      }

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.