I am new to javascript and jQuery. I have loaded a JsonData.json
file. I need help to loop through all the data and display it in a HTML table when the user clicks a button.
<script>
var a = {};
$.getJSON('JsonData.json', function (data) {
a = data;
});
</script>
My table structure is below:
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>IDNumber</th>
</tr>
</table>
My "JsonData.json" file structure is below:
[
{
"ID": 1,
"Name": "John Smith",
"IDNumber": "7606015012088"
},
{
"ID": 2,
"Name": "Molly Malone",
"IDNumber": "8606125033087"
},
{
"ID": 3,
"Name": "Rianna Chetty",
"IDNumber": "6207145122087"
},
{
"ID": 4,
"Name": "Gregory Nazul",
"IDNumber": "8112125042088"
},
{
"ID": 5,
"Name": "Mary Billat",
"IDNumber": "9103317012087"
},
{
"ID": 6,
"Name": "Harry Popadopalous",
"IDNumber": "7206085031088"
},
{
"ID": 7,
"Name": "Jim Beam",
"IDNumber": "5101236012088"
}
]