Search the web
Sign In
New User? Sign Up
ajaxcfc · ajaxCFC Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
accessing value(s) from json array   Message List  
Reply | Forward Message #1580 of 1584 |
Re: [ajaxcfc] accessing value(s) from json array

This is a matter of case sensitivity. JavaScript is case sensitive, and for some reason object properties are returned all uppercased. Look at the dump and you'll see that it's "PRICE" not "price". This was a big gotcha for me when I started too.

Just use aUPSprice[0].PRICE and you should be fine. :o)

Cheers,
Chris

On Thu, Feb 12, 2009 at 9:30 AM, josegura93 <jsegura01@...> wrote:

I having a tough time trying to access a value from my return. Below
is my ajax call:

$.AjaxCFC({
url: '/cfc/ups.cfc',
method: 'getShippingOptions',
data: {'shiptozip': zipVal,'weight': weightVal,
'serviceCode': servCodeVal},
unnamedargs: false,
serialization: 'json',
success: function(aUPSprice){
alert(aUPSprice[0].price); /* looking for
price value but alert displays "Undefined" */
$.dump(aUPSprice);
}
});
})

The dump:
array
0[object]
object
PRICE [number] 6.89
OPTION [string] Ground

1[object]
object
PRICE [number] 7.32
OPTION [string] 3 Day Select





--
http://cjordan.us


Thu Feb 12, 2009 4:21 pm

c_s_jordan
Offline Offline
Send Email Send Email

Forward
Message #1580 of 1584 |
Expand Messages Author Sort by Date

I having a tough time trying to access a value from my return. Below is my ajax call: $.AjaxCFC({ url: '/cfc/ups.cfc', method: 'getShippingOptions', data:...
josegura93
Offline Send Email
Feb 12, 2009
3:30 pm

This is a matter of case sensitivity. JavaScript is case sensitive, and for some reason object properties are returned all uppercased. Look at the dump and...
Chris Jordan
c_s_jordan
Offline Send Email
Feb 12, 2009
4:21 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help