Re: SOT: Using jQuery to access the JSON that CF8 returns?
You need to JSON.parse() the result. On Fri, Aug 15, 2008 at 12:39 AM, Andy Matthews <[EMAIL PROTECTED]> wrote: > I'm using jQuery to make a direct CFC call, with the optional returnFormat > parameter. > > Here's the get call: > > $.get("coupons.cfc?method=getSingleCoupon", { >couponid: couponid, >siteid: siteid, >returnFormat:'JSON' > },function(d){ >// alert(d['DATA'][0][0]); >console.log(d); >$container.css({ >'background-image': 'none' >}); > }); > > Here's the result when I log to the console: > -- > { >"COLUMNS":["ID","TITLE"], >"DATA":[ >[4,"15% Off A Timing Belt Package"] > ] > } > > So it's an object with an array named COLUMNS, and one named DATA. I should > be able to reference the title like so: > > d['DATA'][0][1]; > > But when I do so in Firefox, using Firebug I get the error: > > d.DATA has no properties > coupons.js > Line 68 > > What am I doing wrong? -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311029 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: SOT: Using jQuery to access the JSON that CF8 returns?
On Thu, Aug 14, 2008 at 11:39 AM, Andy Matthews <[EMAIL PROTECTED]> wrote: > I'm using jQuery to make a direct CFC call, with the optional returnFormat > parameter. > d['DATA'][0][1]; > > But when I do so in Firefox, using Firebug I get the error: > > d.DATA has no properties > coupons.js > Line 68 > > What am I doing wrong? > For queries returned in JSON, I I use a jsonencode function by Jehiah Czebotar. It adds a RECORDCOUNT variable and then I reference returned data like so: for (var i=0; ihttp://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310999 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
SOT: Using jQuery to access the JSON that CF8 returns?
I'm using jQuery to make a direct CFC call, with the optional returnFormat parameter. Here's the get call: $.get("coupons.cfc?method=getSingleCoupon", { couponid: couponid, siteid: siteid, returnFormat:'JSON' },function(d){ // alert(d['DATA'][0][0]); console.log(d); $container.css({ 'background-image': 'none' }); }); Here's the result when I log to the console: -- { "COLUMNS":["ID","TITLE"], "DATA":[ [4,"15% Off A Timing Belt Package"] ] } So it's an object with an array named COLUMNS, and one named DATA. I should be able to reference the title like so: d['DATA'][0][1]; But when I do so in Firefox, using Firebug I get the error: d.DATA has no properties coupons.js Line 68 What am I doing wrong? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310995 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4