can someone please help me to fix this? i am not sure what is wrong with the code
i have a simple JSON and i need to get these data as Bootstrap tables.
JSON file is like this :
[
{
"telephoneNumber": "03-7946 2800",
"isoCountryCode": "BN",
"line3": "Bandar Seri Begawan",
"cityName": "Brunei",
"line2": "Kampung Kiulap",
"line1": "6 & 7, Block A, Kompleks Shakirin",
"careOfName": "",
"state": "BR",
"emailAddress": "vhwzezgj@rzrcy.bmh",
"postalCode": "BE1518",
"id": "8804188225559"
},
{
"telephoneNumber": "5494492",
"isoCountryCode": "BN",
"line3": "GADONG",
"line4": "8171571",
"cityName": "BDR SERI BEGAWAN",
"line2": "KAMPONG RIMBA",
"line1": "5 SIMPANG 12-32",
"careOfName": "",
"state": "BR",
"emailAddress": "vhwzezgj@rzrcy.bmh",
"postalCode": "BE3119",
"id": "8802223521815"
},
]
i wrote a html code like this
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<title>Hello, world!</title>
</head>
<body>
<p><br></p>
<div class="container">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>telephoneNumber</th>
<th>isoCountryCode</th>
<th>line3</th>
<th>cityName</th>
<th>line2</th>
<th>line1</th>
<th>careOfName</th>
<th>state</th>
<th>emailAddress</th>
<th>postalCode</th>
<th>id</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script >
$.getJSON("data.json",function(data){
var items=[];
$.each(data,function(key,val){
items.push("<tr>");
items.push("<td id='" + key+" '>"+val.telephoneNumber+"</td>");
items.push("<td id='" + key+" '>"+val.isoCountryCode+"</td>");
items.push("<td id='" + key+" '>"+val.line3+"</td>");
items.push("<td id='" + key+" '>"+val.cityName+"</td>");
items.push("<td id='" + key+" '>"+val.line2+"</td>");
items.push("<td id='" + key+" '>"+val.line1+"</td>");
items.push("<td id='" + key+" '>"+val.careOfName+"</td>");
items.push("<td id='" + key+" '>"+val.state+"</td>");
items.push("<td id='" + key+" '>"+val.emailAddress+"</td>");
items.push("<td id='" + key+" '>"+val.postalCode+"</td>");
items.push("<td id='" + key+" '>"+val.id+"</td>");
items.push("</tr>");
});
$("<tbody/>",{html:items.join("")}).appendTo("table");
})
</script>
</body>
</html>
When i run the page, i could see the data is not populating to Bootstrap Tables. Not sure why. can someone please help? I am sitting with this code since Friday but not able to fix it