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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:35:29+00:00 2026-06-04T12:35:29+00:00

I am trying to work with json and I almost have what I need.

  • 0

I am trying to work with json and I almost have what I need. I am getting the correct info to display but I am having to pass each item of an array into a variable and then print the variable. I would like to display all of the items in each array. The json data I am working with is from an invoicing app (http://www.curdbee.com) and I am trying to show each invoice for a client. The data that I want to show is each line item, the line item price, and the total amount. Here is my code:

$(document).ready(function() {


    $.getJSON('https://nspirelab.curdbee.com/invoices.json?api_token=__token__', function(data){
        $.each(data, function(index, item){
            var total = item.invoice.total_billed;
            var lineItemName1 = item.invoice.line_items[0].name_and_description;
            var lineItemName2 = item.invoice.line_items[1].name_and_description;
            var lineItemPrice1 = item.invoice.line_items[0].price; 
            var lineItemPrice2 = item.invoice.line_items[1].price; 

            $('#results').append('<div class="lineItem"><ul><li>' + lineItemName1 + lineItemPrice1 + '</li><li>' + lineItemName2 + lineItemPrice2 + '</li><li>' + total + '</li></ul></div>');
        });

    });

});
  • 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-04T12:35:31+00:00Added an answer on June 4, 2026 at 12:35 pm

    A nested loop (or, in jQuery, a nested $.each()) will do the job:

    $.getJSON('https://nspirelab.curdbee.com/invoices.json?api_token=&client=104929', function(data){
       $.each(data, function(index, item){
          // create an empty ul (initially disconnected from the DOM)
          var $ul = $("<ul/>");
    
          // iterate over the line items
          $.each(item.invoice.line_items, function(i, lineItem) {
             // create an li element with the line details and append
             // it to the ul
             $ul.append( $("<li/>").html(lineItem.name_and_description + lineItem.price) );
          });
    
         // add the totals to the end of the ul
         $ul.append( $("<li/>").html(item.invoice.total_billed) );
    
         // create a new div, append the ul to it, and append the div to results
         $('#results').append( $('<div class="lineItem"/>').append($ul) );
       });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to work with the Google Calendar JSON API, but have been
Hey guys I'm trying to work my way through this but am having an
I have a JSON array of objects, and am trying to work out how
Very beginner level question. Trying to learn JSON and having trouble with getting proper
I am currently trying to work with json and objective-c however having a bit
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I'm trying to work on a new project parsing some JSON data for a
I'm trying to get work this code: $(#list).jqGrid({ url: 'employers.php', datatype: 'json', mtype: 'POST',
I usually work with .NET but I have a php page that calls an
I'm trying to add formatted json string to my textarea field. But it doesn't

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.