• 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);

    }

  • 相关阅读:
    轮播图适应代码jQ
    jQuery focus、blur事件 添加、删除类名
    节点操作js jQuery
    动态加载jQuery
    底边滑动变色的列表
    节点选择只有链接
    第三方登录过程—OAuth2.0协议
    JavaScript中常谈的对象
    浅谈JavaSccript函数与对象
    JavaScript与DOM的关系
  • 原文地址:https://www.cnblogs.com/wslpf/p/9386163.html
Copyright © 2020-2023  润新知