最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to correctly use Bootstrap table data-url property? - Stack Overflow

programmeradmin3浏览0评论

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=".3.7/css/bootstrap.min.css">
<link rel="stylesheet" href=".11.1/bootstrap-table.css">

</head>

<body>

<table class ="table table-hover" id ="table" data-toggle="table" data-url=".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=".2.1/jquery.min.js"></script>
<script src=".3.7/js/bootstrap.min.js"></script>
<script src=".11.1/bootstrap-table.js"></script>
<script>
    $(table).bootstrapTable('refresh', {
        url: '.json'
    });
</script>

</html>

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./bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare./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./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./ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/bootstrap-table/1.11.1/bootstrap-table.js"></script>
<script>
    $(table).bootstrapTable('refresh', {
        url: 'https://raw.githubusercontent./wenzhixin/bootstrap-table-examples/master/json/data1.json'
    });
</script>

</html>

Share Improve this question asked Apr 22, 2017 at 23:39 Syed Ahmed JamilSyed Ahmed Jamil 2,1113 gold badges23 silver badges38 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

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/en-US/docs/Web/Security/Same-origin_policy

发布评论

评论列表(0)

  1. 暂无评论