<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie-edge">
</head>
<body>
<table class="table table-stripped">
<tbody id="data">
</tbody>
</table>
<script>
fetch("wig.json").then(
res=>{
res.json().then(
data=>{
console.log(data);
if(data.length > 0){
var tmp = '';
data.forEach((u)=>{
tmp +="<tr>";
tmp += "<td>"+u.Name+"</td>";
tmp += "<td>"+u.Oprice+"</td></tr>";
})
document.getElementById("data").innerHTML = tmp;
};
}
)
}
)
</script>
</body>
</html>
I can fetch the local json data and I can see all my json data in the console. Yet. I can't display it using table and there is no any error statement shown. Can someone help me to fix this problem. I reference the code from:https://www.youtube.com/watch?v=WMQ2sq1dw6Y&t=230s