var test = true; window.onload = function (ev) { init(); } init = function () { getOrderInfo(1, 10); } getOrderInfo = function (pageindex, pagesize) { var parameter = urlEncode(["SelectIpAddress", pageindex, pagesize]); $.ajax({ type: "post", url: "/taiwan/php/index.php", data: {mode: parameter}, dataType: "json", success: function (data) { if (data.length == 0 || data == -1) { $("#loading").css({"display": "none"}); $("#warp").css({"display": "table-row-group"}); var th = '暂无数据'; $("#warp").html(th); $("#Page").html(""); // $("#warp").append(th); return; } printOrderInfo(data); if (test) { test = false; var totalSize = data[0].allcount, totalPage = Math.ceil(totalSize / pagesize); // $("#Page").whjPaging("setPage", {currPage: pageindex, totalPage: totalPage, totalSize: totalSize}); $("#Page").whjPaging({ currPage: pageindex, totalSize: totalSize,//可选,总条数 totalPage: totalPage,//可选,总页数 isShowRefresh: false,//可选,是否展示刷新,默认true isShowPageSizeOpt: false,//可选,是否展示每页条数下拉框,默认true,如果设置显示,总条数必须设置 // isResetPage:true, callBack: function (currPage) { $("#loading").css({display: "block"}); $("#warp").css({display: "none"}); getOrderInfo(currPage, pagesize); // console.log('currPage:' + currPage + ' pageSize:' + pageSize); } }); } } }); } printOrderInfo = function (data) { var warp = $("#warp"), tr; warp.html(""); for (var i = 0; i < data.length; i++) { href = "'product-add.html?pid=" + data[i].ProductId + "'"; tr = '' + '' + data[i].OrderNum + '' + '' + data[i].IPAddress + '' + '' + data[i].Country + '' + '' + data[i].City + '' + '' + data[i].AddTime + '' + ''; warp.append(tr); } $("#loading").css({"display": "none"}); $("#warp").css({"display": "table-row-group"}); } urlEncode = function (arr) { var i; //循环初始化 for (i = 0; i < arr.length; i++) { arr[i] = encodeURIComponent(encodeURIComponent(arr[i])); } return arr.join(); }