Copy link to clipboard
Copied
Hi all,
I'm having a problem setting the results of a query to a variable. What I'm trying to do is make an AJAX call to a .cfc file and pass back the results of the function. The main problem is, I'm trying to pass back a block of HTML code ( resulting from a cfquery to a cfoutput ) stored in a variable. My code is something like..
<cffunction name="getText" access="remote" returntype="void">
<cfquery datasource="#request.dsn#" name="queryTable">
SELECT infoA, infoB
FROM infoTable
</cfquery>
<cfset result = '<!--- this is the part I'm stuck on, I want the table to go here. --->'>
<table>
<cfoutput query="tablequery">
<tr>
<td>#infoA#</td><td>#infoB#</td>
</tr>
</cfoutput>
</table>
<cfwddx action="cfml2js" input="#result#" toplevelvariable="r">
</cffunction>
This is a simplified version of what I want to do, but you get the idea..
Is this even the right way of going about it?? Thanks
That is what I get for trying the e-mail reply feature! Aren't you glad I double checked my post.
You could do a bunch of string concatenation here doing stuff like <cfset result = result & "<td>" & infoA & "</td><td>" & infoB & "</td>"> over and over again. But really the <cfsaveContent...> tags is so much easier to use.
<cfsaveContent variable="result">
<table>
<cfoutput query="tablequery">
<tr>
<td>#infoA#</td><td>#infoB#</td>
</tr>
</cfoutput>
</table>
</cfsaveContent>
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That is what I get for trying the e-mail reply feature! Aren't you glad I double checked my post.
You could do a bunch of string concatenation here doing stuff like <cfset result = result & "<td>" & infoA & "</td><td>" & infoB & "</td>"> over and over again. But really the <cfsaveContent...> tags is so much easier to use.
<cfsaveContent variable="result">
<table>
<cfoutput query="tablequery">
<tr>
<td>#infoA#</td><td>#infoB#</td>
</tr>
</cfoutput>
</table>
</cfsaveContent>
Copy link to clipboard
Copied
You are the best. I didn't even think of that. Thanks so much for the help! ![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more