[jQuery] Re: Basic JSON help

2007-08-16 Thread Erik Beeson
I'm not quite sure which part you're asking about. To get and interact with your example data, you could do something like: $.getJSON('/url/to/json', function(data) { for(var i = 0; i data.models.length; i++) { $('#output').append('div' + data.models[i] + '/div'); // or whatever you want

[jQuery] Re: Basic JSON help

2007-08-16 Thread Erik Beeson
Right, 'count' doesn't have any special meaning that I know of. What are you expecting it to be? Arrays have a special property called length, which you could access like json.models.length, but Objects (like your json variable), don't necessarily have this special property. --Erik On 8/16/07,

[jQuery] Re: Basic JSON help

2007-08-16 Thread Michael Geary
From: jeff w I am new to jQuery, and have started to play with JSON,but I need some info about how I refer to the JSON Object once it is returned from the server. I know I can loop through the contents of the object, and I can use json.count, but I am really unsure about the correct

[jQuery] Re: Basic JSON help

2007-08-16 Thread Erik Beeson
I assumed he was using $.getJSON or something similar that takes care of the eval'ing for you. --Erik On 8/16/07, Michael Geary [EMAIL PROTECTED] wrote: From: jeff w I am new to jQuery, and have started to play with JSON,but I need some info about how I refer to the JSON Object once

[jQuery] Re: Basic JSON help

2007-08-16 Thread Michael Geary
Oh, you're right, Erik, I wasn't paying close enough attention to the related thread. Jeff, skip the eval in the code I listed if it's coming from $.getJSON. :-) -Mike _ From: Erik Beeson I assumed he was using $.getJSON or something similar that takes care of the eval'ing for you.

[jQuery] Re: Basic JSON help

2007-08-16 Thread jeff w
Thats it! I was referring to the length as 'count'. Thats why my for loop wasn't executing, and thats why I couldn't echo my data in the browser. Thanks! So, should I treat my JSON object like a Javascript multi-dimensional array? On Aug 16, 10:20 am, Erik Beeson [EMAIL PROTECTED] wrote:

[jQuery] Re: Basic JSON help

2007-08-16 Thread jeff w
Yes, I am using $.getJSON. eval() is a javascript function right? so if I want more info on that, I should look at a javascript reference?? what is console.debug()? I've seen that in a bunch of posts. I am guessing its a way to output results. Is it a cleaner way of using something like

[jQuery] Re: Basic JSON help

2007-08-16 Thread Erik Beeson
Like Mike said, you don't need eval() when using $.getJSON(). That console.* stuff is part of a FireFox extension called FireBug that's fairly standard for doing development. --Erik On 8/16/07, jeff w [EMAIL PROTECTED] wrote: Yes, I am using $.getJSON. eval() is a javascript function right?

[jQuery] Re: Basic JSON help

2007-08-16 Thread Michael Geary
So, should I treat my JSON object like a Javascript multi-dimensional array? Seeing as how JavaScript doesn't *have* multi-dimensional arrays, I probably wouldn't put it exactly that way. :-) But you definitely have the right idea. JSON is simply a text representation of JavaScript objects,

[jQuery] Re: Basic JSON help

2007-08-16 Thread polyrhythmic
Jeff, Firebug and Web Developer extensions for Firefox will become very useful for you. There is also a jQuery extension for Firebug debugging: http://jquery.glyphix.com/ Good instructions on that page. A JSON (or other Javascript) Object != a multidimensional array. Javascript objects can be