当前位置:Gxlcms > JavaScript > 使用DataTable插件实现异步加载数据详解

使用DataTable插件实现异步加载数据详解

时间:2021-07-01 10:21:17 帮助过:13人阅读

本文主要给大家分享的是Jquery+dataTable插件来实现异步加载数据的示例代码,非常实用,有需要的小伙伴可以参考下,希望能帮助到大家。

table部分代码


<table class="table table-bordered table-striped" id="table-main">
  <thead>
  <tr>
    <th>用户名</th>
    <th>渠道名</th>
    <th>游戏名</th>
    <th>结果</th>
    <th>耗时</th>
    <th>创建时间</th>
  </tr>
  </thead>
</table>

异步加载数据并实现定制化

下面是简单例子, 其中 table-main 的初始化元素为table的id。


后台数据返回格式


{
 "total": 234,
 "per_page": "25",
 "current_page": 1,
 "last_page": 10,
 "next_page_url": "http://local.dgc_sdkops.com/monitor/log_pack/getRecodeList?page=2",
 "prev_page_url": null,
 "from": 1,
 "to": 25,
 "data": [
  {
   "id": 128,
   "user_id": 1,
   "task_id": "package_128_113",
   "channel_version_id": 128,
   "game_version_id": 113,
   "extend_id": 0,
   "type": "pack",
   "status": 2,
   "remark": "",
   "cast_time": 93475,
   "created_at": "1500365068",
   "updated_at": "1500458543",
   "user_name": "admin",
   "format_created_at": "2017-07-18 16:04:28",
   "format_updated_at": "2017-07-18 16:04:28",
   "game": "x",
   "channel": "y",
   "game_id": 11290,
   "channel_id": 67
  },
  {
   "id": 240,
   "user_id": 1,
   "task_id": "package_128_113",
   "channel_version_id": 128,
   "game_version_id": 113,
   "extend_id": 0,
   "type": "pack",
   "status": 0,
   "remark": "",
   "cast_time": 0,
   "created_at": "1500458454",
   "updated_at": "1500458454",
   "user_name": "admin",
   "format_created_at": "2017-07-19 18:00:54",
   "format_updated_at": "2017-07-19 18:00:54",
   "game": "x",
   "channel": "y",
   "game_id": 11290,
   "channel_id": 67
  }
 ]
}

相关推荐:

jquery dataTable 获取某行数据方法

jquery dataTable 后台加载数据并分页

JQuery.dataTables表格插件跳转到指定页实例分享

以上就是使用DataTable插件实现异步加载数据详解的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行