$.ajax({
type: "get", //使用get方法访问后台
dataType: "json", //返回json格式的数据
url: "/cslv/documentation.do", //要访问的后台地址
data: {
action : "queryFile",
pageNo: pageNo
//where: "where"
}, //要发送的数据
success: function(json) {//msg为返回的数据,在这里做数据绑定
$.each(json.data, function(i, item) {
var downpath ='<%=basePath%>'+item.FILEPATH+item.ID+'.'+item.FILETYPE;
$("#jgcsTable").append("<tr id='neRow' height='25px' class='box_ul'><td width='15' class='box_gray'> </td><td align='left'>"+
item.FILETITLE+"</td><td align='center'>"+item.FILESIZE+"</td><td align='center'>"+
item.FILETYPE+"</td><td align='center'><a style='cursor:pointer' οnclick=\"javascript:download('"+downpath+"')\" class='orange' >下载</a></td></tr>");
});
var pageNo = json.pageNo;//当前页
var pageCount = json.fileCount/json.pageSize == 1?json.fileCount/json.pageSize:json.fileCount/json.pageSize+1; //得到总页数
//显示上一页
if(pageNo > 1){
$("#pages_id").append( "<a class='prev' href='javascript:back("+pageNo+")'>上一页</a>");
}
//<显示分页码
$("#pages_id").append( "<strong>"+pageNo+"</strong>");
alert("=="+parseInt(pageCount));
if(pageNo != parseInt(pageCount)){
$("#pages_id").append( "<a class='next' href='javascript:next("+pageNo+")'>下一页</a>");
}
$("#pages_id").append(" <strong>共"+json.fileCount+"条数据</strong>");
},
/**
function (XMLHttpRequest, textStatus, errorThrown) {
// 通常 textStatus 和 errorThrown 之中
// 只有一个会包含信息
//this; // 调用本次AJAX请求时传递的options参数
},
**/
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(textStatus);
alert("加载数据失败");
//return;
}
// dataFilter:function(data,type){
// alert(data);
// }
/**
error: function() {
alert("加载数据失败");
return;
} //加载失败,请求错误处理
**/
});
dataFilter (data,type)
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(textStatus);
//return;
}
【JSP】测试Ajax
最新推荐文章于 2022-05-25 16:37:09 发布