Код: Выделить всё
// 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 = `
${item.name}
${item.age}
${item.city}
`;
tbody.appendChild(row);
});
})
.catch(error =>console.error('Error fetching the data:', error));
Подробнее здесь: https://stackoverflow.com/questions/790 ... javascript