This is the JSON i have
{
"version": "5.2",
"user_type": "online",
"user":
[
{
"name": "John",
"id": 50
},
{
"name": "Mark",
"id": 57
}
]
}
The javascript to convert the above JSON to HTML
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: "http://PATH/user.json",
dataType: 'json',
type: 'get',
cache:false,
success: function(data){
/*console.log(data);*/
var event_data = '';
$.each(data, function(index, value){
/*console.log(value);*/
event_data += '<tr>';
event_data += '<td>'+value.name+'</td>';
event_data += '<td>'+value.id+'</td>';
event_data += '<tr>';
});
$("#list_table_json").append(event_data);
},
error: function(d){
/*console.log("error");*/
alert("404. Please wait until the File is Loaded.");
}
});
});
</script>
The HTML code for table :
<table class="table table-responsive table-hover table-bordered" id="list_table_json">
<thead>
<tr>
<th>Name</th>
<th>ID</th>
</tr>
</thead>
</table>
Did not get any error's in the console
The output i get in the table says undefined. how to push the data to json ?