如何正确使用Bootstraptabledata-url属性?
How to correctly use Bootstrap table data-url property?
我正在尝试弄清楚如何使用 Bootstrap table 的数据-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>
查看浏览器调试器中的网络选项卡。由于同源策略,您很可能会收到 400 错误。浏览器无法*从与其托管的域不同的域请求内容。
*大体上是正确的,有很多方法可以解决这个问题。
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
我正在尝试弄清楚如何使用 Bootstrap table 的数据-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>
查看浏览器调试器中的网络选项卡。由于同源策略,您很可能会收到 400 错误。浏览器无法*从与其托管的域不同的域请求内容。
*大体上是正确的,有很多方法可以解决这个问题。
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy