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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:41:15+00:00 2026-05-28T03:41:15+00:00

I have a JSON output and i want to show each item inside each

  • 0

I have a JSON output and i want to show each item inside each <li>.

The JSON output looks like this:

var data = [
{
    "MachineID":"171914",
    "Cost":"13,642.41",
    "Currency":"PHP"
},
{
    "MachineID":"172233",
    "Cost":"1,367.73",
    "Currency":"PHP"
},
{
    "MachineID":"41116",
    "Cost":"2,608.20",
    "Currency":"PHP"
},
{
    "MachineID":"178077",
    "Cost":"1,517.04",
    "Currency":"PHP"},
{
    "MachineID":"176430",
    "Cost":"20,876.72",
    "Currency":"PHP"
}
]

And my code is this:

$.each(data, function(i, obj) {
    $.each(obj, function(i, val) {
      $('li').append(obj.MachineID); 
    });
});

Now the result shows like this:

   Foo 171914171914171914172233172233172233411164111641116178077178077178077176430176430176430
   Bar 171914171914171914172233172233172233411164111641116178077178077178077176430176430176430

I may have overlooked something on jQuery.each call and I need only to show one MachineID per <li>, the output should be like this:

    Foo 171914
    Bar 172233
    Baz 41116
    Qux 178077

and so on..

  • 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-05-28T03:41:16+00:00Added an answer on May 28, 2026 at 3:41 am

    If these are existing li elements, the best way would be to select the li elements, iterate them, and use the index in the iteration to grab the data.

    $('li').slice(0,data.length)
           .each(function(i,el){
               $(this).append(data[i].MachineID);
           });
    

    I used .slice() so that if there are more li elements than data, it won’t try to access non-existent data.

    Demo: http://jsfiddle.net/MYC4J/


    If the <li> elements do not yet exist, then you’d need to create them:

    var ul = $('ul');
    
    $.each(data,function(i,obj) {
        $('<li>',{text:obj.MachineID}).appendTo(ul);
    });
    

    Demo: http://jsfiddle.net/MYC4J/1/

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

Sidebar

Related Questions

I am new to json. I have json output that looks like this [
I have a json output array like this { data: [ { name: Ben
I have a json output that looks like this.. { XXXX: { name: Dalvin
I have a JSON output like the following: [City1,City2,City3] I want to get each
I have something like a json array output, it comes like : { data:
I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have a simple scenario where i want to output only json to the
I have queried yahoo finance for historic data and have got JSon output. What
I have a YQL output JSON string at this URL: YQL JSON I found
If i have a php file that outputs json data with numerical keys, like

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.