I'm using Json Data to populate my Html Table with list of Details. I have json file called example.json inside the same directory as index.html page is. But It dosen't show / read json file when I add "example.json" in below code but works perfectly fine when I load online url. I would like to populate the Table with Json File from local storage and when online overwrite the previous Data of example.json with new Data if there is any automatically.
Here is my HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="table-responsive">
<h1>Json</h1>
<br/>
<table class="table table-bordered table-striped" id="employee_table">
<tr>
<th>Class</th>
<th>Time</th>
</tr>
</table>
</div>
</div>
</body>
</html>
<script >
$(document).ready(function(){
$.getJSON("https://api.myjson.com/bins/8qktd", function(data){
var employee_data= '';
$.each(data, function(key, value){
employee_data += '<tr>';
employee_data += '<td>'+value.class+'</td>';
employee_data += '<td>'+value.time+'</td>';
employee_data += '</tr>';
});
$('#employee_table').append(employee_data);
});
});
</script>
a
[
{
"id":"1",
"time":"10-15",
"class":"John Smith"
},
{
"id":"2",
"time":"10-15",
"class":"John Smith"
},
{
"id":"3",
"time":"10-15",
"class":"John Smith"
},
{
"id":"4",
"time":"10-15",
"class":"John Smith"
},
{
"id":"5",
"time":"10-15",
"class":"John Smith"
},
{
"id":"6",
"time":"10-15",
"class":"John Smith"
},
{
"id":"7",
"time":"10-15",
"class":"John Smith"
},
{
"id":"8",
"time":"10-15",
"class":"John Smith"
},
{
"id":"9",
"time":"10-15",
"class":"John Smith"
},
{
"id":"10",
"time":"10-15",
"class":"John Smith"
},
{
"id":"11",
"time":"10-15",
"class":"John Smith"
},
{
"id":"12",
"time":"10-15",
"class":"John Smith"
}
]
Any help would be really much appreciated. I already looked for solution , but found nowhere.