Posted on 2010-08-04 10:59
java小爬蟲 閱讀(1679)
評論(0) 編輯 收藏
一個簡單的jquery分頁,記錄下來,以防自自己遺忘。可能不具有可讀性,還請見諒!請恕java后臺代碼不展現!
jsp頁面部分:
<DIV class="CC_RC">
<UL class='CC_Title'><LI class='CC_TitleName'>任務名稱</LI><LI class='CC_TechTypeName'>所屬行業</LI><LI>設計費用(¥)</LI><LI>發布日期</LI></UL>
<div id="technologyRInfoDIV">
<jsp:include page="/homePage.do?method=getTechnologyRInfo"></jsp:include>
</div>
<div id="techRPageInfo" align="right" >
</div>
</DIV>
js部分:

$(document).ready(function()
{


$.ajax(
{
type: "POST",
url: "./homePage.do?method=getTechnologyRInfoPageSize",
success: function(msg)

{
var pageLength = parseInt(msg);

if(pageLength>1)
{
$("#techRPageInfo").append("<a href='#' onClick='return techRPage("+ pageLength +","+ pageLength +");' >上一頁 </a>");
$("#techRPageInfo").append("<a href='#' onClick='return techRPage(2,"+ pageLength +");' >下一頁 </a>");
}

}
})

});





function techRPage(curpage,maxLength)
{

$.ajax(
{
type: "POST",
url: "./homePage.do?method=getTechnologyRInfo&curpage="+curpage,
success: function(msg)

{
$("#technologyRInfoDIV").html("");
$("#technologyRInfoDIV").html(msg);
$("#techRPageInfo").html("");
var previPage = curpage - 1;
if(previPage == 0) previPage = maxLength ;
$("#techRPageInfo").append("<a href='#' onClick='return techRPage("+ previPage +","+ maxLength +");' >上一頁 </a>");
var nextPage = 0 ;

if(curpage < maxLength)
{
nextpage = curpage + 1 ;
$("#techRPageInfo").append("<a href='#' onClick='return techRPage("+ nextpage +","+ maxLength +");' >下一頁 </a>");

}else if(curpage == maxLength)
{
$("#techRPageInfo").append("<a href='#' onClick='return techRPage(1,"+ maxLength +");' >下一頁 </a>");
}

}
})
}