House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

Return JSON from a CFC

Author:
Raymond Camden
01/05/2009 10:21 PM

> The reason I'm making a web service is b/c I want the JSON to be parsed by > jQuery.  Are you telling me client-side Javascript can handle CFCs? jQuery doesn't read WSDL (afaik). Therefore - you don't want a WSDL response. You want a JSON response. You can call any CFC, under web root, with just the url. Try it. Put this CFC under your web root: <cfcomponent> <cffunction name="sayHi" access="remote" returnType="string"> <cfreturn "Ray roxors"> </cffunction> </cfcomponent> If you name this test.cfc, and put it in web root, open your browser to: http://yourhost/test.cfc?method=sayHi You wlll see a response. If you view source, you will see it is XML, in this case, WDDX. To switch to JSON, do: http://yourhost/test.cfc?method=sayHi&returnFormat=json Any CFC under web root, and any method with access=remote, can be directly called by your ajax code. > > >


Search cf-talk

February 11, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29