基于jquery的无刷新分页技术

复制代码 代码如下:

<script src="script/jquery-1.6.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var index = 0;
$(document).ready(function () {
$.post("Default5.aspx",{ name: index },function (msg) {
$("tr:gt(0)").remove();
var artice = msg;
for (var i = 0; i < 5; i++) {
$("table").append("<tr><td>" + artice[i]["ID"] + "</td><td>" + artice[i]["Writer"] + "</td><td>" + artice[i]["Title"] + "</td></tr>");
}
},"json");
});
$(document).ready(function () {
$("a").click(function () {
if ($(this).html() == "下一页") {
index = index + 5;
if (index > 10) {
index = 10;
}
}
if ($(this).html() == "上一页") {
index = index - 5;
if (index < 0) {
index = 0;
}
}
// alert(index);
$.post("Default5.aspx",function (msg) {
// alert(msg[0]["ID"]);
$("tr:gt(0)").remove();
var artice = msg;
for (var i = 0; i < 5; i++) {
// alert("11");
$("table").append("<tr><td>" + artice[i]["ID"] + "</td><td>" + artice[i]["Writer"] + "</td><td>" + artice[i]["Title"] + "</td></tr>");
// $("table").append("<tr><td>1</td><td>2</td><td>3</td></tr>");
}
},"json");
});
});
</script>

相关文章

问题背景 最近小伙伴提了一个希望提高后台下拉列表可操作性的...
// n位随机数生成 function randomNum(n) { let sString = &...
HTML是HyperText Markup Language的简称,中文名称:超文本标...
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现...
JavaScript 是脚本语言,是一种解释性脚本语言(代码不进行预...
本文由葡萄城技术团队原创并首发 转载请注明出处:葡萄城官网...