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"     } ] }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education