Parsing returned query results in javascript.

I thought dot notation would do the trick, but I was wrong.  My query will only ever return one row.  How do I access my query structure in my script (line 12).  The two columns that I will process will be 'paragraph' and 'contentID'.

	<cfajaximport>
	<cfajaxproxy cfc="admin.com.emailUI.emailUI" jsclassname="jsObj" />
	
	<cfoutput>
		<script type="text/javascript">
			function getPage(pageName) {
				alert('pageName: ' + pageName);
				$('##cpnTbCntnt').empty();
				$('##cpnTbCntnt').html(pageName);
				var cfcAsAjax = new jsObj();
				var cfcReturn = cfcAsAjax.getCoupon(page=pageName,dsn='#request.dsn#');
				document.getElementById('cpnTbCntnt').innerHTML = '<div style=" margin: 14px 0px 0px 0px; height: 420px; width: 742px; text-align: center; overflow: scroll; ">' +  cfcReturn.Paragraph + '</div>';
			}
		</script>
	</cfoutput>

Open in new window

LVL 1
brianmfallsAsked:
Who is Participating?
 
leakim971PluritechnicianCommented:
do you have a link to see the page?

else try :

1) be careful with the case : cfcReturn[0].Paragraph is not cfcReturn[0].paragraph
2) not sure where you want to put/write cfcReturn[0].contentID
3) if you have more than one record use a loop
4) you may need to prevent error when no result is returned if()
<cfajaximport>
	<cfajaxproxy cfc="admin.com.emailUI.emailUI" jsclassname="jsObj" />
	
	<cfoutput>
		<script type="text/javascript">
			function getPage(pageName) {
				alert('pageName: ' + pageName);
				$('##cpnTbCntnt').empty();
				$('##cpnTbCntnt').html(pageName);
				var cfcAsAjax = new jsObj();
				var cfcReturn = cfcAsAjax.getCoupon(page=pageName,dsn='#request.dsn#');
				document.getElementById('cpnTbCntnt').innerHTML = '<div style=" margin: 14px 0px 0px 0px; height: 420px; width: 742px; text-align: center; overflow: scroll; ">' +  cfcReturn[0].Paragraph + '</div>';
			}
		</script>
	</cfoutput>

Open in new window

0
 
brianmfallsAuthor Commented:
Thank you leakim.  That makes perfect sense.  :)
0
 
brianmfallsAuthor Commented:
This is what worked:

document.getElementById('cpnCntnt').innerHTML = cfcReturn[0].Paragraph;

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.