I am trying to figure out how to use the data-url property of Bootstrap table Here is my code. I have added all the necessary CSS/JS files and referenced a correct JSON form file in the the data-url property but still it ain't showing any results. What am I missing here ?
<!doctype html>
<html lang="en">
<head>
<!-- Required CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.1/bootstrap-table.css">
</head>
<body>
<table class ="table table-hover" id ="table" data-toggle="table" data-url="https://raw.githubusercontent.com/wenzhixin/bootstrap-table-examples/master/json/data1.json">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
</body>
<!-- Required js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.11.1/bootstrap-table.js"></script>
<script>
$(table).bootstrapTable('refresh', {
url: 'https://raw.githubusercontent.com/wenzhixin/bootstrap-table-examples/master/json/data1.json'
});
</script>
</html>
Look in the network tab in your browser debugger. Most likely you're getting a 400 error because of the Same-origin Policy. The browser can't* request content from a different domain than the one it's hosted on.
*Generally true, there are ways around this.
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy