一个·用来处理json数据的js文件,传过来的json数据是
{"infos":[{"id":402881e9564b22f701564b251aef0001,"title":"火影","publishingTime":"2016-08-02 20:05:38.0","isEditable":"true"},{"id":402881e9565a7f3601565a86f0c30001,"title":"龙珠","publishingTime":"2016-08-05 19:46:48.0","isEditable":"true"},{"id":402881e9565a7f3601565a8720ac0002,"title":"哈哈","publishingTime":"2016-08-05 19:47:00.0","isEditable":"true"},{"id":402881e9565a7f3601565a87464b0003,"title":"海贼","publishingTime":"2016-08-05 19:47:10.0","isEditable":"true"},{"id":402881e9565a7f3601565a87b47c0004,"title":"海贼王","publishingTime":"2016-08-05 19:47:38.0","isEditable":"true"}],"pageBean":{"pageSize":5,"currentPage":1,"totalPage":1,"hasPrevious":false,"HasNext":false}}处理json数据的文件是
var pageIndex = 1;//首页
$(function () {
ajaxGetListData(pageIndex);
});
//ajax获开列表
function ajaxGetListData(index) {
$.ajax({
url: "getFirstInfoList.action",
type: "Post",
data: "page=" + index,
dataType: "json",
success: function (data) {
var htmlStr = "";
htmlStr += "";
htmlStr += "";
htmlStr +=""
+"序号"
+"用户ID"
+"标题"
+"创建时间"
+"";
htmlStr += "";
htmlStr += "";
for (var i = 0; i < data.infos.length; i++) {
htmlStr += "";
htmlStr += "" + (i+1) + ""
+ ""+ data.infos.id + ""
+ ""+ data.infos.title+ ""
+""+ data.infos.publishingTime+ "";
htmlStr += "";
}
if(data.infos.length==0){
htmlStr += ""+ '暂无记录' + "";
}
htmlStr += "";
htmlStr += "";
htmlStr += "";
htmlStr += "";
htmlStr += "显示";
htmlStr += "每页" + data.pageBean.pageSize + "条记录_共" + data.pageBean.totalPage+ "页_"+"当前第"+data.pageBean.currentPage+"页" + "";
htmlStr += "";
htmlStr += "";
if(data.pageBean.currentPage > 1){
htmlStr += "首 页 ";
}else{
htmlStr += "首 页  ";
}
if((data.pageBean.currentPage - 1 ) > 0 ){
htmlStr +="上一页  ";
}else{
htmlStr +="上一页  ";
}
if((data.pageBean.currentPage+1) > data.pageBean.totalPage){
htmlStr += "下一页 ";
}else{
htmlStr += "下一页 ";
}
if(data.pageBean.currentPage < data.pageBean.totalPage){
htmlStr += "尾 页 ";
}else{
htmlStr += "尾 页  ";
}
htmlStr += " ";
htmlStr += "";
htmlStr += "";
htmlStr += "";
htmlStr += "";
$("#divSearchResult").html(htmlStr);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest);
alert(textStatus);
alert(errorThrown);
}
});
}
//首页
function GoToFirstPage() {
pageIndex = 1;
ajaxGetListData(pageIndex);
}
//上一页
function GoToPrePage() {
pageIndex -= 1;
pageIndex = pageIndex >= 0 ? pageIndex : 0;
ajaxGetListData(pageIndex);
}
//下一页
function GoToNextPage() {
if (pageIndex < parseInt($("#count").text())) {
pageIndex += 1;
}
ajaxGetListData( pageIndex);
}
//尾页
function GoToEndPage() {
pageIndex = parseInt($("#count").text());
ajaxGetListData(pageIndex);
}
//跳转
function GoToAppointPage(e) {
var page = $(e).prev().val();
if (isNaN(page)) {
alert("请输入数字!");
}
else {
var tempPageIndex = pageIndex;//pageIndex==currentPage
pageIndex = parseInt(page);
if (pageIndex < 0 || pageIndex > parseInt($("#count").text())) {
pageIndex = tempPageIndex;
alert("请输入有效的页面范围!");
}else {
ajaxGetListData(pageIndex);
}
}
}
2016/10/12 23:53:24
放下 2016/10/12 23:53:24
社区主页
经过测试里面的函数就是不执行,有可能是什么原因 |