What I'm trying to do is to fill a table with some info from JSON file big.json, I need to do this with jQuery.
It looks like this now but not working:
<div class="stink">
<table>
<tr>
<th>Car</th>
<th>fault1</th>
<th>fault2</th>
</tr>
<script>
$.getJSON( "data.json", function( data ) {
var items = [];
$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
</script>
</table>
</div>
the JSON file structure is:
{
"Mercedes": {
"fault1":"not working",
"fault2":"key issues"
},
"BMW": {
"fault1":"not starting",
"fault2":"control problem"
}
}
How can I parse in the table those info with JQUERY ?