• Home
  • About George
  • Contact Me
Blue Orange Green Pink Purple

CFAjaxProxy Problems or RTFM

Posted in ColdFusion, Databases, JavaScript. on Monday, May 17th, 2010 by George Tags: ColdFusion, Databases, JavaScript
May 17

So recently I’d been doing a cfselect box using bind to create my desired linked drop down.  The problem I was having was that I wanted to do a zebra stripe on the select after it had been loaded.  I could not find a way to attach the bind event to anything else so I couldn’t call a function after the bind had actually completed.  The way I wanted to solve this was to use a setTimeout on the coloring process.  The problem I was having was that my serializedJSON output I was using was no longer working.  It turns out – if you read the documentation – that using cfajaxproxy to pull in a CFC automatically serializes your output.  So if you’re returning a result of String with a serializeJSON(myQuery) you will end up with the data being DOUBLE SERIALIZED! Oh what a headache that was.  The proper way to do this:

1
2
3
4
5
6
7
8
9
   <cfajaxproxy cfc="myData" jsclassname="myDataClass" />
 
   <script>
	getData = function(){
		var o = new myDataClass();
		var dataset = o.getData($('toggleField').checked);
		return dataset;
	}
   </script>

Is to have your CFC do this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<cfcomponent>
	<cffunction name="getData" access="remote" returntype="query">
		<cfargument name="myToggle" type="string" required="yes" default="false" />
 
		<cfset var qryData = 0 />
 
                <cfquery name="qryData " datasource="DATAS">	
			SELECT *
                           FROM tableData
                </cfquery>
 
		<cfreturn qryData>
	</cffunction>
</cfcomponent>

Rather than serializing it yourself first. If you’re binding with a method of cfc: then you don’t need to do this, instead you need to change it to return text and use the SerializeJSON on your qryData query.

Leave a Reply

Web Development By George

  • About
    About me. Edit this in the options panel.
  • Photo Stream
  • Categories
    • ColdFusion
    • coldspring
    • Databases
    • Design
    • Flash
    • Flex
    • Internet
    • JavaScript
    • jQuery
    • Model-Glue
    • Personal
    • Subversion
    • Uncategorized
    • YUI
  • Recent Articles
    • Radios and JQuery and IE8
    • Coldfusion, Flex, and SSL
    • Leaving it to the Experts
    • CFAjaxProxy Problems or RTFM
    • I love the Internet
    • Interesting ColdFusion Survey
  • Archives
    • November 2011
    • May 2011
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • November 2009
    • October 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
  • Search




Add to Technorati Favorites

  • Home
  • About George
  • Contact Me

© Copyright Web Development By George. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top