>1) Add dataType:'json' as an attribute of your ajax call, or use $.getJSON
>2) use Firebug / console.log to examine the response, make sure DATA is a
>valid property of the response JSON
>
>-- Josh
>
>
>
>I am trying to call a query from a CFC using jQuery with the following code:
>
>$(document).ready(
> function () {
> $.ajax({
> type: "GET",
> url: "SpellChecker.cfc?method=getTextMemoFields&returnformat=json
> &queryformat=column",
> data: datastring,
> success:
> function(response) {
> var resp = jQuery.trim(response);
> alert(resp);
> }
> });
>
>});
>
>When I look at the data inside an alert it looks exactly like it should.
>However, when I try to get to the values inside of it (e.g. resp.DATA) it is
>always undefined. Do I need to perform an extra step? I appreciate any
>advice I can get on this.
>
>Thanks,
>
>JW
Josh,
1. I already am getting the results back in JSON format using the
returnformat=json parameter. I tried $.getJSON without much success (If you
know of a good CFC example using $.getJSON, I'd be happy to review it). I
cannot even get results back using it, where as with the $.ajax I get results,
I just can't seem to do much with them but print the whole json object(i.e.
document.write) to a page or display the results in an alert box.
2. I am Firebug and I did verify that DATA is a valid parameter. Basically I
am returning a db table and putting in JSON format. The code I have returns
the following:
{"ROWCOUNT":20,"COLUMNS":["SAVEDVALUE"],"DATA":{"SAVEDVALUE":["blah,blah,blah"]}}
But when I try and access for instance resp.ROWCOUNT, it's undefined. So
basically, I want to know how I can actually get to the values I can only seem
to read.
Thanks,
James
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:323617
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4