I would recommend, that your getRecordsResult handle the query as
well as the building of your HTML table. Don't use javascript to
build the table.
In your CFC use just use cfsavecontent, and build your table within
there, then just have your CFC return a string rather than a query.
Also with that same function, make a call to your getServiceType
function... in short all of that should be handled on the server
witin 1 CFC (which can make calls to other CFCs if need be), and just
return a string and display it. Why make multiple trips to the
server? This will get around the problem you are having with a delay.
--- In ajaxcfc@yahoogroups.com, "ofarah24" <ofarah24@...> wrote:
>
> I am trying to call a ajax function from another function. It is
> working this way: I send some search criteria to searchRecords and
> searchRecords return multiple records and display them in a table.
> While displaying the results in the table, I called another
function
> and pass it the transactionID to get the services done in each
> transaction. I am not getting any services back. But the weird part
> is that if I put 'alert(serviceType);' right before displaying
> serviceType in the table, the servicetypes appear just fine in the
> table. I don't know why it works with alert() but not without it.
At
> first, I was thinking that may there is some delay in getting the
> results from the 2nd function and the table is displayed before the
> results get back but I tried putting delay code and it still
doesn't
> work. I think I am missing something small here.
>
> //------------------ 1st function
> function searchRecords(form,clientName, staffName, topic,
> specificDate, fromDate, toDate, searchService,transactionID,
> department)
> {
> displayClientInfo = form;
> var oWddx = new WddxSerializer();
> var _o = {form: form, staffName: staffName,
> specificDate: specificDate, fromDate: fromDate, toDate: toDate};
> DWREngine._execute(_ajaxConfig._cfscriptLocation,
> null, 'getRecords', oWddx.serialize(_o), getRecordsResult);
> }
>
> //Call back function for searchRecords
> function getRecordsResult (r) {
> if(r.getRowCount() > 0){
> var out = '<br><table border=1 cellpadding=3
> cellspacing=3><tr><th>Select</th><th>ID</th><th>Client
> Name</th><th>Staff Name</th>';
> out= out + '<th>Date</th><th>Service
> Type</th>';
> ....some code here...
>
> getServices(r.id[x]);
> out = out + "<td valign='top'> " +
> serviceType + "</td>";
> }
> $('searchResults').innerHTML =out + '</table>';
> }
>
>
> //------------------ 2nd function
> function getServices(transID)
> {
> DWREngine._execute(_ajaxConfig._cfscriptLocation,
> null, 'getServiceType', transID, dosomething);
> }
>
> //Call back function for getServices
> function dosomething (r)
> {
> serviceType ='';
> if(r.getRowCount() > 0){
> for (var x = 0; x < r.getRowCount(); x++)
> {
> serviceType = serviceType + r.service[x]
> + ",";
> }
> }
> }
>