日期:2014-05-16 浏览次数:20700 次
<script type="text/javascript"> var count = ""; //统计总记录 function RecordCount() { $.ajax({ dataType: "json", url: "WebService.asmx/XmltoJson", contentType: "application/json;", type: "POST", success: function (xml) { var json = eval('(' + xml.d + ')'); $("#txtCount").val($(json.jinshu.item).length); } }); } //输出数据 function InitData(pageclickednumber) { $.ajax({ dataType: 'json', url: "WebService.asmx/XmltoJson", contentType: "application/json;", //data: { pageindex: pageclickednumber }, type: "POST", success: function (xml) { var tbody = ""; var json = eval('(' + xml.d + ')'); $("#txtCount").val($(json.jinshu.item).length); $.each(json.jinshu.item, function (i, n) { var str = ""; str += "<tr><td>" + n["@newsid"] + "</td><td>" + n["@newstitle"] + "</td><td>" + n["@url"] + "</td><td>" + n["@auditortime"] + "</td><td>" + n["@newssort"] + "</td></tr>"; tbody += str; }); $("#TBODY").append(tbody); } }); } //初始化 $(document).ready(function () { RecordCount(); $("#pager").pager({ pagenumber: 1, pagecount: $("#txtCount").val(), buttonClickCallback: PageClick }); PageClick(1); }); //回调分页 PageClick = function (pageclickednumber) { $("#pager").pager({ pagenumber: pageclickednumber, pagecount: $("#txtCount").val(), buttonClickCallback: PageClick }); InitData(pageclickednumber); } </script>
(function($) { $.fn.pager = function(options) { var opts = $.extend({}, $.fn.pager.defaults, options); return this.each(function() { // empty out the destination element and then render out the pager with the supplied options $(this).empty().append(renderpager(parseInt(options.pagenumber), parseInt(options.pagecount), options.buttonClickCallback)); // specify correct cursor activity $('.pages li').mouseover(function() { document.body.style.cursor = "pointer"; }).mouseout(function() { document.body.style.cursor = "auto"; }); }); }; // render and return the pager with the supplied options function renderpager(pagenumber, pagecount, buttonClickCallback) { // setup $pager to hold render var $pager = $('<ul class="pages"></ul>'); // add in the previous and next buttons $pager.append(renderButton('first', pagenumber, pagecount, buttonClickCallback)).append(renderButton('prev', pagenumber, pagecount, buttonClickCallback)); // pager currently only ha