Pagination(分页) 从前台到后端总结

时间:2025-02-14 20:14:36
1 var pageSize =6; //每页显示多少条记录 2 var total; //总共多少记录 3 $(function() { 4 Init(0); //注意参数,初始页面默认传到后台的参数,第一页是0; 5 $("#Pagination").pagination(total, { //total不能少 6 callback: PageCallback, 7 prev_text: '上一页', 8 next_text: '下一页', 9 items_per_page: pageSize, 10 num_display_entries: 4, //连续分页主体部分显示的分页条目数 11 num_edge_entries: 1, //两侧显示的首尾分页的条目数 12 }); 13 function PageCallback(index, jq) { //前一个表示您当前点击的那个分页的页数索引值,后一个参数表示装载容器。 14 Init(index); 15 } 16 }); 17 18 function Init(pageIndex){ //这个参数就是点击的那个分页的页数索引值,第一页为0,上面提到了,下面这部分就是AJAX传值了。 19 $.ajax({ 20 type: "post", 21 url:"../getContentPaixuServ?Cat="+str+"&rows="+pageSize+"&page="+pageIndex, 22 async: false, 23 dataType: "json", 24 success: function (data) { 25 $(".neirong").empty(); 26 /* total = ; */ 27 var array = ; 28 for(var i=0;i<;i++){ 29 var info=array[i]; 30 31 if( != null){ 32 $(".neirong").append('<dl><h3><a href="'++'?ContentId='++'" title="'++'" >'++'</a></h3><dt><a href="?ContentId='++'" title="'++'" ><img src="<%=basePathPic%>'++'" alt="'++' width="150" height="95""></a></dt> <dd class="shortdd">'++'</dd><span>发布时间:'++'</span></dl>') 33 }else{ 34 $(".neirong").append('<dl ><h3><a href="'++'?ContentId='++'" title="'++'" >'++'</a></h3><dd class="shortdd">'++'</dd><span>发布时间:'++'</span></dl>'); 35 }; 36 } 37 }, 38 error: function () { 39 alert("请求超时,请重试!"); 40 } 41 }); 42 };