- 时间:2022-05-18 09:05 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Jquery:ajax实现翻页无刷新功能代码
不多说,直接贴代码:
下面是js部分:
[url=<%=request.getContextPath()%>/activity_edit.action?id=]+"</tr>"
$("#t_body").html(tbody_content);
}
}else{
$("#t_head").html("");
$("#t_body").html("<div style='height: 200px;width: 700px;padding-top: 100px;' align='center'>"+info.msg+"</div>");
}
}
//清空数据
function clearDate(){
$("#t_body").html("");
}
//搜索活动
$("#searchActivity").click(function(){ queryForPages(); });
//首页
$("#firstPage").click(function(){
currentPage="1";
queryForPages();
});
//上一页
$("#previous").click(function(){
if(currentPage>1){
currentPage-- ;
}
queryForPages();
});
//下一页
$("#next").click(function(){
if(currentPage<totalPage){
currentPage++ ;
}
queryForPages();
});
//尾页
$("#last").click(function(){
currentPage = totalPage;
queryForPages();
});
});
下面是html代码部分:
<table class="table style-5">
<thead id="t_head">
<tr>
<th>序号</th>
<th>标题</th>
<th>地点</th>
<th>已报名</th>
<th>类别</th>
<th>操作</th>
</tr>
</thead>
<tbody id="t_body">
<!-- ajax填充列表 -->
</tbody>
</table>
<button id="firstPage">首页</button>
<button id="previous">上一页</button>
<button id="next">下一页</button>
<button id="last">尾页</button>