我正在尝试弄清楚如何使用Bootstrap表的data-url属性,这里是我的代码。我已经添加了所有必要的CSS/JS文件,并在data-url属性中引用了正确的JSON表单文件,但它仍然没有显示任何结果。这里我漏掉了什么?
<!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>
发布于 2017-04-23 07:44:52
查看浏览器调试器中的网络选项卡。最有可能的是,由于同源策略,你得到一个400错误。浏览器不能*从托管它的域之外的其他域请求内容。
*通常情况下,有办法绕过这一点。
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
https://stackoverflow.com/questions/43565815
复制相似问题