• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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

0
brianmfalls
Asked:
brianmfalls
  • 2
1 Solution
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now