I’m a total loss. I have this function to read the Twitter Json. The Json is valid but the value is coming back as ‘undefined’ when I run it.
$.getJSON("http://twitter.com/users/show.json?screen_name=starbucks&callback=?" , function(data) {
var testing = (data.length);
alert(testing);
})
datais an object* not an array** so it doesn’t have a length property.***Use a debugger like Firebug, Safari/Chrome dev tools and use this code instead:
and you can see that the data is coming back to you perfectly.
Try this to see what I mean, preferably with a JavaScript console available.
*e.g., something that looks like
{key: value, ...}; also known as a hash or an associative array**e.g., something that looks like:
[foo, bar, baz, ...]*** unless, of course, someone was evil and constructed the object like so: