//绘制页面ul
for(var i=1;i $("#page_ul").append(
$(""+i+"")
);
}
}
}
});
}
//翻页
function gotoPage(pageNum){
$.ajax({
url:"data.json",
type:"POST",
dataType:"json",
timeout:1000,
error:function(){
alert("ajax error");
},
success:function(data){
currentPage=pageNum;
startRow=pageSize*(pageNum-1);
endRow=startRow+pageSize;
endRow=(rowTotal>endRow)?endRow:rowTotal;
$("#table tbody").empty();
for(var i=startRow;i $("#table tbody").append(
$(""+ data[i].name+ " | "+ data[i].stargazers_count+ " | "+ data[i].forks_count+ " | "+ data[i].description+ " |
")
);
}
}
});
}
$(function(){
page();
$("#page_ul li").live("click",function(){
var pageNum=$(this).text();
gotoPage(pageNum);
});
$("#page_prev li").live("click",function(){
if(currentPage==1){
}else{
gotoPage(--currentPage);
}
});
$("#page_next li").live("click",function(){
if(currentPage==pageTotal){
}else{
gotoPage(++currentPage);
}
})
});