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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:38:15+00:00 2026-06-17T12:38:15+00:00

I am appending a json response to an html element. The code is very

  • 0

I am appending a json response to an html element. The code is very simple

HTML

<div>
  <ul id='grid'></ul>
</div>

jQuery

data = ["Paintings",{ "age":0}]

$(function() {
   $.each(data, function(i,index) {         
     $('div').find('ul').append('<li>'+index.age+'</li>');
  });
});

The output looks like this

undefined

0

Where is the undefined coming from??

I tried using this to remove the undefined

$('#grid').children(':first-child').remove('li');

but it removes the “0” and the undefined.

http://jsfiddle.net/ccUKH/

  • 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-17T12:38:16+00:00Added an answer on June 17, 2026 at 12:38 pm

    data is an array, the first element of array is a string Paintings. Second element of array is an object with property age.

    The each loops over both elements in array and since string has no property age it creates an LI with text undefined .

    You could change the data structure or look for object or string in array and react accordingly…not sure what you want to do. Not clear what you are doing with Paintings

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 464 JSON objects. An HTML element needs to be generated from each
I am appending html to a <ul> on an ajax success function. HTML <ul
How can I response a page as a json page? Is the code below
When appending HTML from a JSON reply, the event handlers appear to lose their
I am having a difficult time simply appending data to an element from a
I am appending p tags to a div as I process a json request
Via ajax i retrieve some json data, make it as html and append it
I am getting some data in JSON format via jQuery and then I need
Fancybox is appending it's DIV tags at the bottom of my DOM. Is there
I am appending new data - $('#posts').append(data); But I want this new data 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.