Look at the renderings first:
The implementation principle is very simple. It uses the jquery.pagination plug-in. Whenever the page number is clicked, it asynchronously goes to the server to get the data of the page. , a brief introduction is as follows:
1. Database table structure: very simple. The four fields are News_id News_title News_time News_readtimes
2. Foreground page code:
<head runat="server"> <title>JQuery无刷新分页</title> <link href="Styles/common.css" rel="stylesheet" type="text/css" /> <link href="Styles/paging.css" rel="stylesheet" type="text/css" /> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="Scripts/jquery.pagination.js" type="text/javascript"></script> <script type="text/javascript"> var pageIndex = 0; var pageSize = 3; $(function() { InitTable(0); $("#Pagination").pagination(<%=pageCount %>, { callback: PageCallback, prev_text: '上一页', next_text: '下一页', items_per_page: pageSize, num_display_entries: 6,//连续分页主体部分分页条目数 current_page: pageIndex,//当前页索引 num_edge_entries: 2//两侧首尾分页条目数 }); //翻页调用 function PageCallback(index, jq) { InitTable(index); } //请求数据 function InitTable(pageIndex) { $.ajax({ type: "POST", dataType: "text", url: 'Ajax/PagerHandler.ashx', data: "pageIndex=" + (pageIndex + 1) + "&pageSize=" + pageSize, success: function(data) { $("#Result tr:gt(0)").remove();//移除Id为Result的表格里的行,从第二行开始(这里根据页面布局不同页变) $("#Result").append(data);//将返回的数据追加到表格 } }); } }); </script> </head>
<form id="form1" runat="server"> <center> <table id="Result" border="1" cellpadding="5" style="border-collapse: collapse; margin:20px; border: solid 1px #85A8BE;width:60%"> <tr> <th style="width: 10%"> ID </th> <th style="width: 60%"> 标题 </th> <th style="width: 20%"> 更新时间 </th> <th style="width: 10%"> 点击量 </th> </tr> </table> <div id="Pagination" class="paging"> </div> </center> </form>
3. Page background file
Here is mainly to get the total number of records:
public string pageCount = string.Empty;//总条目数 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pageCount = new News().GetNewsCount(); } }
Fourth, the most important thing is the ajax handler: PagerHandler.ashx
public class PagerHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string str = string.Empty; int pageIndex = Convert.ToInt32(context.Request["pageIndex"]); int size = Convert.ToInt32(context.Request["pageSize"]); if (pageIndex == 0) { pageIndex = 1; } int count = 0; News n = new News(); List<News> list = n.GetNewsList(pageIndex, size, ref count); StringBuilder sb = new StringBuilder(); foreach (News p in list) { sb.Append("<tr><td>"); sb.Append(p.News_id); sb.Append("</td><td>"); sb.Append("<a href='#'>"+p.News_title+"</a>"); sb.Append("</td><td>"); sb.Append(p.News_time); sb.Append("</td><td>"); sb.Append(p.News_readtimes); sb.Append("</td></tr>"); } str = sb.ToString(); context.Response.Write(str); } public bool IsReusable { get { return false; } } }
More examples of JQuery+Ajax non-refresh paging For code-related articles, please pay attention to the PHP Chinese website!

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
