Hi,
First of all, your JSON file is not proper. It should be like this.
[{
"ID": 1,
"Name": "John Smith",
"IDNumber": "7606015012088"
},
{
"ID": 2,
"Name": "Molly Malone",
"IDNumber": "8606125033087"
}]
Consider following code snippet. It will load a json file called 'jsondata.json' and creates a table.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script>
function onLoad(){
var url='jsondata.json';
$.getJSON(url, function(json){
var table = $('<table>');
table.attr('border','1');
var tr = $('<tr>');
var td = $('<td>');
td.html("ID");
tr.append(td);
td = $('<td>');
td.html('Name');
tr.append(td);
td = $('<td>');
td.html('IDNumber');
tr.append(td);
table.append(tr);
for( var i=0; i<json.length;i++){
var tr = $('<tr>');
var td = $('<td>');
td.html(json[i].ID);
tr.append(td);
td = $('<td>');
td.html(json[i].Name);
tr.append(td);
td = $('<td>');
td.html(json[i].IDNumber);
tr.append(td);
table.append(tr);
}
$('body').append(table);
});
}
</script>
</head>
<body önload ="onLoad();">
</body>
</html>