I just tried it and my CFC is still returning the JSON content but it seems
like it still appears to be a string rather than an object.  I'm using this:

                        //var wsURL =
'/ws/emp.cfc?method=getEmpInfo&returnFormat=json&searchParam=101';
                        var wsURL =
'http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any
&format=json&jsoncallback=?';
                        $.getJSON(wsURL,
                                        function(jsondata) {
                                        // fnPopEmpList(jsondata);
                                        alert(jsondata);
                                        alert(jsondata.items[1].tags);
                                        // $.each(jsondata.items,
function(i,item){
                                        //      alert(item);
                                        // });
                                }
                        );

When I use Flickr, alert(jsondata) displays [object Object] and I can access
elements like array notes; when I use my CFC alert(jsondata) displays a
string and trying to access elements results in "undefined".


Subject: Return JSON from a CFC
From: Raymond Camden
Date: Mon, 5 Jan 2009 21:13:26 -0600
Thread:
http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:58433#317442


> 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.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317449
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to