首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何正确使用Bootstrap表的data-url属性?

如何正确使用Bootstrap表的data-url属性?
EN

Stack Overflow用户
提问于 2017-04-23 07:39:28
回答 1查看 15K关注 0票数 2

我正在尝试弄清楚如何使用Bootstrap表的data-url属性,这里是我的代码。我已经添加了所有必要的CSS/JS文件,并在data-url属性中引用了正确的JSON表单文件,但它仍然没有显示任何结果。这里我漏掉了什么?

代码语言:javascript
复制
<!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>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-23 07:44:52

查看浏览器调试器中的网络选项卡。最有可能的是,由于同源策略,你得到一个400错误。浏览器不能*从托管它的域之外的其他域请求内容。

*通常情况下,有办法绕过这一点。

https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43565815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档