Fluidbyte
Fluidbyte

Reputation: 5210

Unable to get properties of JavaScript Object

I'm returning JSON from a php file to a jQuery function, and am getting an object output with the properties agt_id and agt_type. With the webkit dev tools I can print see the object, expand it and see the properties. However, I get undefined when I try:

console.log(output.agt_id);

Here's what I'm seeing in my console with console.log(output):

Image from console

Upvotes: 0

Views: 104

Answers (1)

I Hate Lazy
I Hate Lazy

Reputation: 48761

From your screen shot, it looks like your object is in an Array. You can access the object at index 0 of the Array.

console.log(output[0].agt_id);

Upvotes: 5

Related Questions