zoukankan      html  css  js  c++  java
  • ajax分页借鉴

    大家好这是我分页是用的代码希望大家可以相互交流ajax局部刷新

    var pageindex = 1;

    var where = "";
    var Pname = "";
    var sex = "";
    $("#sele").click(function () {
    Pname = $("#Pname").val();
    sex = $("#sex").val();
    where = " Pname like'%" + Pname + "%'";
    if (sex != "") {
    where += " and Sex=" + sex + ""
    }
    Show(pageindex, where);
    })

    Show(pageindex, where);
    function Show(pageindex, where) {
    var pagesize = 2;
    $.ajax({
    type: "get",
    dataType: "json",
    url: "/Home/show",
    data: { pageindex: pageindex, pagesize: pagesize, where: where },
    success: function (data) {

    var add = "";
    var infor = eval(data);
    $("#Showinfor").empty();
    for (var i = 0; i < infor.list.length; i++) {
    add += "<tr><td>" + infor.list[i].Pid + "</td>";
    add += "<td>" + infor.list[i].Pname + "</td>";
    add += "<td>" + infor.list[i].Sex + "</td>";
    add += "<td>" + infor.list[i].Age + "</td>";
    add += "<td>" + infor.list[i].Pboy + "</td>";
    add += "<td>" + infor.list[i].Xname + "</td>";
    add += "<td><a href='#'>删除</a>&nbsp&nbsp<a href='#'>修改</a></td></tr>";
    }
    $("#Showinfor").append(add);
    fen(infor.count, pagesize);
    $("td").attr("align", "center")

    }
    })


    }

    function fen(count, pagesize) {
    //Pname = $("#Pname").val();
    //sex = $("#sex").val();
    //where = " Pname like'%" + Pname + "%'";
    //if (sex != "") {
    // where += " and Sex=" + sex + ""
    //}
    $("#yema").empty();
    var ye = Math.ceil(count / pagesize);
    var str = "";
    for (var i = 1; i <= ye; i++) {
    str += '<a href="#" style="margin-left:5px;" onclick="Show('+i+', where)">' + i + '</a>';
    }
    str += "____ 共" + count + "条"
    $("#yema").append(str);

    }

  • 相关阅读:
    数字麦克风PDM信号采集与STM32 I2S接口应用(四)--单片机源码
    Golang SQL连接池梳理
    Ghost-无损DDL
    蛮好用的网站
    齿轮
    water
    折纸 (模拟)
    不等式(数学)
    周期串查询
    大集训模拟赛十一
  • 原文地址:https://www.cnblogs.com/wslpf/p/9386163.html
Copyright © 2011-2022 走看看