My code is like this                      Books Data                                                                                      id              Book name              description              price              author              type              img              inCart              category                                                                     i need to retrieve json data in html table but data won't retreive      XML file data   {   "Book": [     {       "id": "b1",       "Book name": "The Power of HABIT",       "description": "The Power of HABIT: Why We Do What We Do in Life and Business. A young woman walks into a laboratory. Over the past two years, she has transformed almost every aspect of her life. She has quit smoking, run a marathon, and been promoted at work. The patterns inside her brain, neurologists discover, have fundamentally changed.",       "price": 16.33,       "author": "Charles Duhigg",       "type": "hardcover",       "img": "https://images-na.ssl-images-amazon.com/images/I/51ejXdSceNL._AA300_.jpg",       "inCart": false,       "category": "business"     },     {       "id": "b2",       "Book name": "Think and Grow Rich",       "description": "'Think and Grow Rich!' explains entrepreneur Andrew Carnegie’s secret to success, revealed to Napoleon Hill during private interviews with Carnegie, the richest man of his time, and during more than 20 years of research into the lives and philosophies of more than 500 of the most successful people in America. This timeless classic presents a systematic nuts-and-bolts approach to developing the skills and mindset required to achieve exceptional success in any field or endeavor, personal or professional. Hill explains in detail 13 steps required to achieve those goals. The book contains numerous self-tests and checklists.",       "price": 8.98,       "author": "Napoleon Hill",       "type": "hardcover",       "img": "https://images-na.ssl-images-amazon.com/images/I/51ZouHoBGtL._SX315_BO1,204,203,200_.jpg",       "inCart": false,       "category": "business"     } ] }

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter6: Working With Tables And Columns: Creating A Program Schedule For A Radio Station
Section: Chapter Questions
Problem 8CP3
icon
Related questions
Question

My code is like this 

<!doctype html>
<html>
    <head>
       
        <title>Books Data</title>
        <script src=
"https://code.jquery.com/jquery-3.5.1.js">
    </script>
        <style>
           
            table
            {
                width=100%;
               
            }
            th
            {
                background-color:grey;
            }
            td
            {
                background-color:cyan;
            }
           
           
        </style>
       
       
       
    </head>
    <body>
       
     <table id="myTableData">
         <tr>
             <th>id</th>
             <th>Book name</th>
             <th>description</th>
             <th>price</th>
             <th>author</th>
             <th>type</th>
             <th>img</th>
             <th>inCart</th>
             <th>category</th>
             
         </tr>
         
         
     
     <script>
        $(document).ready(function () {

            // FETCHING DATA FROM JSON FILE
            $.getJSON("Book.json",
                    function (data) {
                var student = '';

                // ITERATING THROUGH OBJECTS
                $.each(data, function (key, value) {

                    //CONSTRUCTION OF ROWS HAVING
                    // DATA FROM JSON OBJECT
                    student += '<tr>';
                    student += '<td>' +
                        value.id + '</td>';

                    student += '<td>' +
                        value.Book name + '</td>';

                    student += '<td>' +
                        value.description + '</td>';

                    student += '<td>' +
                        value.price + '</td>';

                        student += '<td>' +
                        value.author + '</td>';

                        student += '<td>' +
                        value.type + '</td>';

                        student += '<td>' +
                        value.img + '</td>';

                        student += '<td>' +
                        value.inCart + '</td>';

                        student += '<td>' +
                        value.category + '</td>';

                    student += '</tr>';
                });
                 
                //INSERTING ROWS INTO TABLE
                $('#myTableData').append(student);
            });
        });
    </script>
     
</body>

</html>
 
 
 
i need to retrieve json data in html table but data won't retreive 
 
 
XML file data
 
{
  "Book": [
    {
      "id": "b1",
      "Book name": "The Power of HABIT",
      "description": "The Power of HABIT: Why We Do What We Do in Life and Business. A young woman walks into a laboratory. Over the past two years, she has transformed almost every aspect of her life. She has quit smoking, run a marathon, and been promoted at work. The patterns inside her brain, neurologists discover, have fundamentally changed.",
      "price": 16.33,
      "author": "Charles Duhigg",
      "type": "hardcover",
      "img": "https://images-na.ssl-images-amazon.com/images/I/51ejXdSceNL._AA300_.jpg",
      "inCart": false,
      "category": "business"
    },
    {
      "id": "b2",
      "Book name": "Think and Grow Rich",
      "description": "'Think and Grow Rich!' explains entrepreneur Andrew Carnegie’s secret to success, revealed to Napoleon Hill during private interviews with Carnegie, the richest man of his time, and during more than 20 years of research into the lives and philosophies of more than 500 of the most successful people in America. This timeless classic presents a systematic nuts-and-bolts approach to developing the skills and mindset required to achieve exceptional success in any field or endeavor, personal or professional. Hill explains in detail 13 steps required to achieve those goals. The book contains numerous self-tests and checklists.",
      "price": 8.98,
      "author": "Napoleon Hill",
      "type": "hardcover",
      "img": "https://images-na.ssl-images-amazon.com/images/I/51ZouHoBGtL._SX315_BO1,204,203,200_.jpg",
      "inCart": false,
      "category": "business"
    }
]
}
 
 
 
I can not locate mistake
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

still not retrieve json data code is as following

 

<!doctype html>
<html>

<head>

 <title>Books Data</title>
 <script src="https://code.jquery.com/jquery-3.5.1.js">
 </script>
 <style>
  table {
   width=100%
  }

  th {
   background-color: grey
  }

  td {
   background-color: cyan
  }
 </style>

 

</head>

<body>

 <table id="myTableData">
  <tr>
   <th>id</th>
   <th>Book name</th>
   <th>description</th>
   <th>price</th>
   <th>author</th>
   <th>type</th>
   <th>img</th>
   <th>inCart</th>
   <th>category</th>

  </tr>

 

  <script>
   $(document).ready(function () {

    // FETCHING DATA FROM JSON FILE
    $.getJSON("Book.json",
     function (data) {
      var student = '';

      // ITERATING THROUGH OBJECTS
      $.each(data, function (key, value) {
       // console.log("v", value)
       //CONSTRUCTION OF ROWS HAVING
       // DATA FROM JSON OBJECT
       value.map(e => {

        var res = student += '<tr>'
        student += '<td>' +
         e.id + '</td>'

        student += '<td>' +
         e["Book name"] + '</td>'

        student += '<td>' +
         e.description + '</td>'

        student += '<td>' +
         e.price + '</td>'

        student += '<td>' +
         e.author + '</td>'

        student += '<td>' +
         e.type + '</td>'

        student += '<td>' +
         e.img + '</td>'

        student += '<td>' +
         e.inCart + '</td>'

        student += '<td>' +
         e.category + '</td>'

        student += '</tr>'
        return res

       })

      })

      //INSERTING ROWS INTO TABLE
      $('#myTableData').append(student)
     })
   })
  </script>

</body>

</html>
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage