0

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

1
  • 3
    Could you post the object structure you're seeing with the dev tools? Commented Sep 24, 2012 at 21:34

1 Answer 1

5

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);
Sign up to request clarification or add additional context in comments.

1 Comment

@Fluidbyte also, if you put dataType: 'json' in your original jQuery ajax call, jQuery should automatically parse the response JSON string into a javascript object for you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.