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

    }

  • 相关阅读:
    金蝶问题:不能保存已审核的单据
    在代码中设置cxTreeList按多列排序
    日积月累篇:生产任务单
    sp_reset_connection
    日积月累篇:仓库流程
    使用FreeMarker生成Word文档 仅此而已
    ASP格式化时间日期(二)
    省市区三级联动连接数据库
    利用SQL语句进行添加、删除、修改字段,表与字段的基本操作,数据库备份等
    ASP截取字数(二)
  • 原文地址:https://www.cnblogs.com/wslpf/p/9386163.html
Copyright © 2011-2022 走看看