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 7732307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:41:56+00:00 2026-06-01T06:41:56+00:00

I have a pretty basic problem but I can’t seem to figure it out…

  • 0

I have a pretty basic problem but I can’t seem to figure it out…

This is my ajaxcall via jquery:

function noname(){

    $.ajax({
        type : 'POST',
        url : 'somefile.php',
        dataType : 'json',
        success : function(data){

            $('#user').text(data.info.name).fadeIn(500);


        },
        error : function(XMLHttpRequest, textStatus, errorThrown) {

        }
    });

}

Let’s say somefile.php outputs this:

{"proceed":"1","info":{"name":"John","online":"Online","id":"1"}}

In this case, everything works fine, and the user-div appears, containing the text “John”.

However, let’s say somefile.php outputs this:

{"proceed":"1","info":[{"id":"1","name":"John"},{"id":"2","name":"Rick"},{"id":"3","name":"Jane"},{"id":"4","name":"Astrid"}]}

To visualize it, here’s the print_r of the array:

Array
(
[proceed] => 1
[info] => Array
    (
        [0] => Array
            (
                [id] => 1
                [name] => John
            )

        [1] => Array
            (
                [id] => 2
                [name] => Rick
            )

        [2] => Array
            (
                [id] => 3
                [name] => Jane
            )

        [3] => Array
            (
                [id] => 4
                [name] => Astrid
            )
    )
)

I want to output the same thing as I did in the working scenario, so I would put this in the ajax-call:

$('#user').text(data.info.0.name).fadeIn(500);

This gives an error, since I can’t use numbers there.
Anyone knows how to handle this?

Thanks a lot!!!

  • 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-01T06:41:57+00:00Added an answer on June 1, 2026 at 6:41 am

    Since “info” is an array, you can simply access its entries like this:

    data.info[0].name
    

    Works the same for objects:

    data['info'][0].name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty basic problem I can't figure out when using jQuery simplemodal:
So this seems pretty basic but I can't get it to work. I have
I realize this question is pretty basic, but I'm really stuck. I have a
Pretty basic programming question, I know PHP have a function for it, but does
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
I am learning Java and have a pretty basic problem. I am indexing some
Pretty basic problem here. So I have a Java package that I have created
This may be a basic question but I am pretty new to DDD. I
I am sure this has something to do with IIS but I can't figure
I know this is a pretty basic question, but I don't know how to

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.