On Wed, Feb 29, 2012 at 7:46 PM, <[email protected]> wrote: > Directly from javascript. >
You can use CFAJAXPROXY for that: http://www.openbd.org/manual/?/tag/CFAJAXPROXY Basically that lets you create an instance of your CFC as a JavaScript class and work with the object in JavaScript. Let's assume you have a CFC called AjaxCFC.cfc that returns a query object, something like: <cfcomponent output="false"> <cffunction name="getData" access="remote" output="false" returntype="query"> <cfquery name="foo" datasource="foo"> SELECT * FROM foo </cfquery> <cfreturn foo /> </cffunction> </cfcomponent> Then on a .cfm page you can do: <cfajaxproxy cfc="AjaxCFC" jsclassname="jsClass" /> <script> myJSClass = new jsClass(); // this is your CFC in JavaScript now theData = myJSClass.getData(); // this calls the CFC method </script> It's that simple. Now you have your query data in JavaScript. If you do things this way your query data will come back as JSON formatted data (you can use Firebug or the Chrome developer tools to see the data). Specifically it'll be a JSON object with two attributes, "columns" and "data", and the data attribute will be an array of JavaScript arrays containing all your query data. There's a lot of flexibility with all of this such as you can use SerializeJSON(), specify a returnformat of JSON, and lots of other options. -- Matthew Woodward [email protected] http://blog.mattwoodward.com identi.ca / Twitter: @mpwoodward Please do not send me proprietary file formats such as Word, PowerPoint, etc. as attachments. http://www.gnu.org/philosophy/no-word-attachments.html -- online documentation: http://openbd.org/manual/ google+ hints/tips: https://plus.google.com/115990347459711259462 http://groups.google.com/group/openbd?hl=en
