【发布时间】:2019-07-12 13:41:54
【问题描述】:
我有一个数据表,我想使用 API 动态显示数据。如何做到这一点我的 API 是 url,我正在使用 bootstrap4 datattable。这是我的fiddle。谁能建议我如何做到这一点或任何例子?提前致谢。
$(document).ready(function(){
$('#example').DataTable( {
ajax: "https://api.myjson.com/bins/un18a",
deferRender: true,
scrollY: 200,
scrollCollapse: true,
scroller: true,
initComplete: function ()
{
this.api().row( 1000 ).scrollTo();
}
});
});
<table class="table table-bordered" id="example" width="100%" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Subject</th>
<th>Message</th>
<th>Details</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
【问题讨论】:
-
您在执行此操作时遇到了什么问题?
-
@Mayank Pandeyz 我无法显示数据。
-
试试这个:github.com/pandeyz/…
标签: javascript jquery html datatable bootstrap-4