Bootstrap表加载外部数据 - 未找到匹配的记录

时间:2015-04-28 05:12:47

标签: javascript jquery html twitter-bootstrap bootstrap-table

我试图让插件Bootstrap Table与官方网站(http://bootstrap-table.wenzhixin.net.cn/examples/)上提供的示例代码一起使用。出于某种原因,它似乎不起作用,我得到的只是"没有找到匹配的记录"。 这是我的jsFiddle http://jsfiddle.net/1r3s3qjn/,它基于官方示例http://jsfiddle.net/wenyi/e3nk137y/14/light/,它有效。

我尝试加载的数据也来自官方网站:http://wenzhixin.net.cn/p/bootstrap-table/docs/data1.json

代码段:

<table data-toggle="table" data-url="http://wenzhixin.net.cn/p/bootstrap-table/docs/data1.json">
    <thead>
        <tr>
            <th data-field="id">Id</th>
            <th data-field="name">Name</th>
            <th data-field="price">Price</th>
        </tr>
    </thead>
</table>

任何人都可以使用这个简单的例子吗?

编辑:

我只是设法让它在本地工作(代码和数据都保存在本地)。但是,这似乎只适用于Firefox(37.0.2)。 Chrome(42.0.23)和IE11都显示&#34;未找到匹配的记录&#34;。

1 个答案:

答案 0 :(得分:1)

显示与 Cross origin / Access-Control-Allow-Origin 问题相关的错误。 提供来自同一域的数据。

或尝试http://bootstrap-table.wenzhixin.net.cn/examples/#basic-table-from-data。使用CORS读取数据并调用bootstrapTable函数。