pagination.js通过ajax请求获取数据

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 01:28   297   0
参考https://www.cnblogs.com/chenluomenggongzi/p/6362705.html与pagination.js API

 1  $.ajax({
 2         url: 'test.json',
 3         type: 'GET',
 4         dataType: 'json',
 5         success: function (data) {
 6             console.log(data.items.length);
 7             var item = data.items, length = data.items.length, pageIndex;
 8             //默认页面显示内容
 9             showBox.html('姓名:' + item[0]['name'] + '\n' + '年龄:' + item[0]['age'] + '姓名:' + item[1]['name'] + '\n' + '年龄:' + item[1]['age']);
10             $("#M-box").pagination({
11                 totalData: length,
12                 showData: 2,
13                 jump: true,
14                 coping: true,
15                 homePage: '首页',
16                 endPage: '末页',
17                 prevContent: '上页',
18                 nextContent: '下页',
19                 callback: function (index) {
20                     pageIndex = index.getCurrent() - 1;
21                     showBox.html('姓名:' + item[pageIndex]['name'] + '\n' + '年龄:' + item[pageIndex]['age'] + '姓名:' + item[pageIndex]['name'] + '\n' + '年龄:' + item[pageIndex]['age']);
22                 }
23             })
24         },
25         error: function () {
26             //错误处理
27             alert("操作超时,请刷新页面重试!");
28         }
29     })

转载于:https://www.cnblogs.com/He-tao-yuan/p/10006140.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP