Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ajax pagination complete code finishing

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

/ * ajax pagination * / var page_cur = 1; / / current page var total_num, page_size, page_total_num / / Total records, pages per page, total pages function getData (page) {/ / get current page data $.ajax ({type: 'GET', url: processing data address, data: {' page': page, 'catid':' {$video_info.catid}'}, dataType: 'json' Success: function (json) {$("# ul_lists") .empty () Total_num = json.total_num; / / Total records page_size = json.page_size; / / number of pages per page page_cur = page; / / current page page_total_num = json.page_total_num; / / total pages var li = "; var list = json.list $.each (list, function (index, array) {/ / traversal returns json var curid = {$video_info.id}; var cur = curid = = array ['id']? "class='cur'": "; li + ="+ array ['title'] +" + array [' time'] + ";}); $(" # ul_lists ") .append (li);}, complete: function () {getPageBar () / / js generates pagination, can be replaced by program}, error: function () {alert ("data exception, please check whether json format";}});} function getPageBar () {/ / js generate paging if (page_cur > page_total_num) page_cur = page_total_num; / / the current page is greater than the maximum number of pages if (page_cur)

< 1) page_cur = 1; //当前页小于1 page_str = "共" + total_num + "条" + page_cur + "/" + page_total_num + ""; if(page_total_num >

1) {if (page_cur = = 1) {/ / if the first page page_str + = "Home page previous";} else {page_str + = "Home page previous";} if (page_cur > = page_total_num) {/ / if the last page page_str + = "next last page" } else {page_str + = "next last page";} $("# page") .html (page_str);} $(function () {getData (1)) / / default first page $("# page a") .live ('click', function () {/ / live adds event handlers to future elements, not available bind var page = $(this) .attr ("data-page"); / / get the current page getData (page)});})

The data processor queries the data for the normal receiving parameters and then returns to the json foreground for processing.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report