October 22, 2024
Chicago 12, Melborne City, USA
HTML

why json file value is not displayed (javascript)


  <script>
        // Fetch JSON data
        fetch('dat.json')
               .then(response => response.json())
            .then(data => {
                const tbody = document.querySelector('#dataTable tbody');
                data.forEach(item => {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td>${item.name}</td>
                        <td>${item.age}</td>
                        <td>${item.city}</td>
                    `;
                      tbody.appendChild(row);
                });
            })
                .catch(error =>console.error('Error fetching the data:', error));
    </script>

why json file value is not displayed the code i took from chatgpt i tried vscode and notepad +++ too none of them work.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video