Search the web
Sign In
New User? Sign Up
ajaxcfc · ajaxCFC Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Calling a function from another function   Message List  
Reply | Forward Message #1563 of 1584 |
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'>&nbsp;" +
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]
+ ",";
}
}
}




Tue May 20, 2008 8:41 pm

ofarah24
Offline Offline
Send Email Send Email

Forward
Message #1563 of 1584 |
Expand Messages Author Sort by Date

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...
ofarah24
Offline Send Email
May 20, 2008
8:41 pm

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...
geneaiello123
Offline Send Email
May 21, 2008
5:23 pm

Thank you so much for your help. It is working now. Farrah geneaiello123 <programmer_neo@...> wrote: I would recommend, that your getRecordsResult handle...
Farah Omar
ofarah24
Offline Send Email
May 21, 2008
8:10 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help