jquery ajax
<script> <br /> $(function() { <br /> bindResize(document.getElementById('menu')); <br /> //树形菜单 <br /> $("#browser").treeview(); <br /> //分页开始 <br /> var ymym; <br /> //页面索引 b=0 <br /> var ymsy = 0; <br /> //显示行数a=10 <br /> var xshs = 10; <br /> //总行数 c=100 <br /> var zhs; <br /> //分页参照 <br /> var scc = 1; <br /> var sclen = 10; <br /> var cs = 1; <br /> //节点单击事件 <br /> $('#Button1').click(function() { <br /> alert('dblclick'); <br /> $(this).addClass("select").parent().siblings().children().removeClass("select"); <br /> $('#sp1>span').remove(); <br /> ymsy = 0; <br /> xshs = 10; <br /> scc = 1; <br /> sclen = 10; <br /> cs = 1; <br /> $('table>tbody>tr>td').remove(); <br /> $.post('dataServers.ashx', { ccid: "h_xuxu" }, function(data) { <br /> var html = ''; <br /> for (i = xshs * ymsy; i < xshs * (ymsy + 1); i++) { <br /> html += '<tr><td>' + data[i].id + '<td>' + data[i].category + '<td>' + data[i].name + ''; <br /> } <br /> $('.gridtable1').append(html); <br /> //初始化分页HTML,读取总页数 <br /> $.post('dataServers.ashx', { ccoid: 'h_xuxu' }, function(data) { <br /> zhs = data; <br /> fy(zhs, xshs, ymsy, cs); <br /> //显示页码xsym <br /> xsym(ymsy); <br /> }, 'json'); <br /> //点击一次下一页 <br /> $('#next').click(function() { <br /> alert('下一页' + ymsy); <br /> //点击下一页 <br /> ymsy = ymsy + 1; <br /> // alert('ymsy=' + ymsy); <br /> var pf = parseFloat(zhs / xshs); <br /> alert('pf=' + pf); <br /> //当返回数据为10的整数行 <br /> if (ymsy == pf) { <br /> ymsy = parseInt(zhs / xshs) - 1; <br /> alert("=" + ymsy); <br /> alert('已经是最后一页!'); <br /> } <br /> //当返回数据为非10的整数行 <br /> else if (ymsy > parseFloat(zhs / xshs)) { <br /> ymsy = parseInt(zhs / xshs); <br /> alert(">" + ymsy); <br /> alert('已经是最后一页!'); <br /> } <br /> //当返回数据为最后一行 <br /> else if (ymsy == parseInt(zhs / xshs)) { <br /> alert("last" + ymsy); <br /> $('#last').trigger('click'); <br /> } <br /> else { <br /> //数据读到第11页时切换span <br /> aaa(10, ymsy); <br /> if (ymsy == 10 * cs) { <br /> alert('==' + ymsy); <br /> nfy(zhs, xshs, ymsy, cs); <br /> cs += 1; <br /> } <br /> } <br /> //显示页码xsym <br /> xsym(ymsy); <br /> }); <br /> //点击上一页 <br /> $('#prev').click(function() { <br /> alert('上一页' + ymsy); <br /> //点击上一页 <br /> ymsy = ymsy - 1; <br /> if (ymsy < 0) { <br /> ymsy = 0; <br /> alert('已经是第一页!'); <br /> } <br /> else { <br /> // alert('sYS' + ymsy); <br /> //当页面索引>10,单击上一页回到初始span <br /> var htmSpan = ""; <br /> // alert('Scs' + cs); <br /> if (ymsy == 10 * (cs - 1) - 1) { <br /> $('#sp1>span').remove(); <br /> fanYe((cs - 2) * 10 + 1, ymsy + 1, htmSpan); <br /> cs--; <br /> } <br /> aaa(10, ymsy); <br /> } <br /> //显示页码 <br /> xsym(ymsy); <br /> }); <br /> //首页 <br /> $('#first').click(function() { <br /> ymsy = 0; <br /> var htmSpan = ""; <br /> //如果<9 <br /> if (zhs / xshs < 9) { <br /> $('#sp1>span').remove(); <br /> fanYe(ymsy + 1, parseInt(zhs / xshs) + 1, htmSpan); <br /> cs = 1; <br /> } <br /> //如果>=9 <br /> else { <br /> $('#sp1>span').remove(); <br /> fanYe(ymsy + 1, ymsy + 10, htmSpan); <br /> cs = 1; <br /> } <br /> aaa(10, ymsy); <br /> //显示页码 <br /> xsym(ymsy); <br /> }); <br /> //尾页 <br /> $('#last').click(function() { <br /> ymsy = zhs / xshs; <br /> //span翻页 <br /> var htmSpan = ""; <br /> cs = parseInt(ymsy / 10) + 1; <br /> if (zhs % xshs == 0) { <br /> $('#sp1>span').remove(); <br /> fanYe((cs - 2) * 10 + 1, zhs / xshs, htmSpan) <br /> //重置cs的值 <br /> ymsy = parseInt(ymsy) - 1; <br /> lastaaa(10, ymsy, zhs); <br /> } else { <br /> $('#sp1>span').remove(); <br /> fanYe(parseInt(zhs / (10 * xshs)) * 10 + 1, parseInt(zhs / xshs) + 1, htmSpan); <br /> ymsy = parseInt(ymsy); <br /> lastaaa(10, ymsy, zhs); <br /> } <br /> // alert('YMSY' + ymsy); <br /> //显示页码 <br /> xsym(ymsy); <br /> // alert(cs); <br /> }); <br /> //表格隔行变色 <br /> $('tbody>tr:odd').addClass('odd'); <br /> $('tbody>tr:even').addClass('even'); <br /> }, 'json'); <br /> }); <br /> <br /> }) <br /> </script>