Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:09:54+00:00 2026-06-01T09:09:54+00:00

eSo I’ve got some parsed php data whiched I’ve fetched from my database and

  • 0

eSo I’ve got some parsed php data whiched I’ve fetched from my database and then parsed to JSON with json_encode(). Then I’ve used JSONparse() to make objects of my array. My code looks like this:

$.get("fetchDatabase.php", function(data){
var parsedData = jQuery.parseJSON(data);
}

I’m left with the array parsedData which looks like this:

[

{"person0":{"name":["Erik Steen"],"age":["1"]}},
{"person1":{"name":["Frida Larsson"],"age":["1"]}},
{"person2":{"name":["Abdi Sabrie"],"age":["2"]}},
{"person3":{"name":["Achraf Malak"],"age":["3"]}},
{"person4":{"name":["Adam Anclair"],"age":["1"]}}

]

I’ve placed those arrays in an array named

var peopleArray= { people: [ parsedData ] };

So far so good. Now what I want is being able to access certain persons attribute. Like names or age. How do I target those attributes? I’ve tried to print those attributes with no luck. I tried:

alert (peopleArray.people[0].person1.name);

Whiched returns:

Uncaught TypeError: Cannot read property 'name' of undefined

How can I access those attributes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:09:55+00:00Added an answer on June 1, 2026 at 9:09 am

    Apart from the typo (“namn“) the problem is you’re putting an array inside an array:

    var peopleArray = { people: [ parsedData ] };
    

    Since parsedData is an array then what you end up with is a structure like this:

    // peopleArray
    { people :  [ [  { "person0" : ... }, ...  ] ]  }
    //  oops -----^
    

    See the problem? Since parsedData is a already an array the correct code would be:

    var peopleArray = { people: parsedData };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating a XML-RSS type file from PHP. The output for example is
i've used the JQuery function show_hide to hide a box and then display it
I am using a TStream to read binary data (thanks to this post: How
When copying and pasting a bit of sample code from MSDN, I came up
I have a data structure similar to the following picture. Table A has_many Table
Im' trying to write a class BrokenObjectException class derivated from Exception. But in Eclipse
Still making my first steps in Ruby (while dealing with some written code). I
I am using an asp gridview element to do a search on the database
So I've got an AJAX project which uses the XmlHttpRequest object to dynamically retrieve
I have one NSMutableDictionary and it contains the user details. I have used parsing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.