Home  >  Article  >  Backend Development  >  Detailed example of kkpager implementing ajax paging query function

Detailed example of kkpager implementing ajax paging query function

小云云
小云云Original
2017-12-25 10:33:151662browse

This article mainly introduces kkpager to realize the ajax paging query function and paginate data in the foreground. It is suitable when there is a small amount of data. Because the paging data is obtained from the background, it is not recommended for big data. , please refer to this article for the specific front and backend code, I hope it can help you.

Foreground paging data is suitable when there is a small amount of data, because the paging data is obtained from the background. It is not recommended for large data.

Let’s take a look at the front-end code first:


@{
  Layout = null;
}



  
  
  
  
  Index

The back-end code:


##

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace MvcKKpager.Controllers
{
  public class HomeController : Controller
  {
    private readonly int pageSize = 2;
    //
    // GET: /Home/
    public ActionResult Index()
    {
      return View();
    }
    public ActionResult Index2(string pageIndex) {
      List list = new List();
      list.Add("保护环境");
      list.Add("保护环境");
      list.Add("保护环境");
      list.Add("保护环境"); 
      list.Add("保护环境"); 
      var persons = (from p in list select p).Skip((int.Parse(pageIndex) - 1) * pageSize).Take(pageSize);
      StringBuilder builder = new StringBuilder();
      builder.Append("");
      builder.Append("");
      builder.Append("");
      foreach (var item in persons) {
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
        builder.Append("");
      }
      builder.Append("
时间展示点击(点击率)激活(激活率)平均点击单价实际激活成本消耗
" + item + "" + item + "" + item+"" + item + "" + item + "" + item + "" + item + "
"); var result = new { status = "1", data = builder.ToString(), pagecount = list.Count().ToString(), pagesize = pageSize.ToString() }; return Json(result); } } }

There’s nothing much to say

Look at the style


Related recommendations:


Summary of how PHP implements ajax paging

Detailed explanation of the simple implementation of AJAX paging effect

php Ajax paging simple application example_PHP tutorial

The above is the detailed content of Detailed example of kkpager implementing ajax paging query function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn