Here error i can not detect. here i am retrieving xml data in html page in table form by Ajax         Perfume Data                      id    Product name    Brand    Ingredients    Item weight                     XML FILE is like this               p1         Calvin Klein Beauty Eau de Parfum for Women, 100ml         39.99         Calvin Klein         Alcohol Denat, Water, Parfum         1 Pounds                 p2         Burberry London Fabric Eau De Parfum, 100ml         49.99         BURBERRY         Alcohol Denat, Water, Parfum.         100 Grams

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter13: Programming For Web Forms: Creatings Forms For Orders And Pa
Section13.2: Visual Overview: Passing Data Between Forms
Problem 1QC
icon
Related questions
Question
Here error i can not detect. here i am retrieving xml data in html page in table form by Ajax 
 
<!doctype html>
<html>

 

<head>

 

 <title>Perfume Data</title>
 <script src="https://code.jquery.com/jquery-3.5.1.js">
 </script>
 <style>
  table {
            margin: 0 auto;
            font-size: large;
            border: 1px solid black;
        }
 

 

  th {
    font-weight: bold;
            border: 1px solid black;
            padding: 10px;
            text-align: center;
  }

 

  td {
            padding: 10px;
            text-align: center;
            font-weight: lighter;
            background-color: #E4F5D4;
            border: 1px solid black;
  }
 </style>

 

 

 

</head>

 

<body>

 

 <table id="myTableData">
  <tr>
   <th>id</th>
   <th>Product name</th>
   <th>Brand</th>
   <th>Ingredients</th>
   <th>Item weight</th>

 

  </tr>

 

 

 

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

 

    // FETCHING DATA FROM JSON FILE
    $.getJSON("Perfume.XML",
     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.["Product name"] + '</td>'

 

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

 

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

 

        student += '<td>' +
         e.["Item weight"] + '</td>'



        student += '</tr>'
        return res

 

       })

 

      })

 

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

 

</body>

 

</html>
 
 
XML FILE is like this
 
<?xml version="1.0" encoding="UTF-8" ?>
    <Perfume>
        <id>p1</id>
        <Product name>Calvin Klein Beauty Eau de Parfum for Women, 100ml</Product name>
        <Price>39.99</Price>
        <Brand>Calvin Klein</Brand>
        <Ingredients>Alcohol Denat, Water, Parfum</Ingredients>
        <Item weight>1 Pounds</Item weight>
    </Perfume>
    <Perfume>
        <id>p2</id>
        <Product name>Burberry London Fabric Eau De Parfum, 100ml</Product name>
        <Price>49.99</Price>
        <Brand>BURBERRY</Brand>
        <Ingredients>Alcohol Denat, Water, Parfum.</Ingredients>
        <Item weight>100 Grams</Item weight>
    </Perfume>
 
 
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Features of HTML
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