Ok, first of all to get the obligatory warning out of the way.. you need
to be careful with your use of preservesinglequotes().  You're opening
yourself up for a doozy of a SQL injection attack with the searchparam
variable which isn't being sanitized.

On to your question, if I follow what you are doing (I'm a little iffy
on how jQuery works), I don't think you want the ?wsdl on the end of
your web service URL.  What you are telling CF with that is you expect
an XML SOAP packet back with the json return string encoded inside of
it.  jQuery is expecting JUST the JSON returned from a specific method. 
View the url of your web service in a browser window and then VIEW
SOURCE.  The SOAP is there, you're just probably not seeing it.

If you are going to access your web service this way you need to do it
something like this:  
/ws/emp.cfc?method=getEmpInfo&searchparam=myvalue

I know you are using jQuery and all, but the cfajaxproxy tag makes what
you are doing simpler because it does all that stuff for you.

Also, if you want your web service cfc to be reusable in instances where
JSON is not the desired return type I believe you can use the
&returnformat=json in the URL instead of serializing it int he CFC.

~Brad

-------- Original Message --------
Subject: Return JSON from a CFC
From: "Joe" <[email protected]>
Date: Mon, January 05, 2009 1:42 pm
To: cf-talk <[email protected]>

All,
 
I recently created a small CFC returning query results in JSON format.
The
querying works, the regular CF page is able to call the CFC as a WSDL
page
properly passing params, and I am getting back JSON-like content.
However I
have been unable to parse the JSON content like an array within jQuery.
I
put the JSON variable inside an alert function in the CF page and I got
a
JSON-like string.
 
I then replaced the web service URL in my CF page with the one from the
following page:
http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback
When I reloaded the same CF page I got "[object Object]" and I was able
to
parse the results from that web service. So it seems like I'm missing
something in my CFC that turns my JSON content into an object. I hope
it's
something obvious...
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:317417
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to