$(document).ready(function () {
$("#rankTable tbody").html("");
var id = 1;
$.ajax({
url:"bookInfo/bookInfo_rank.action",
type:"POST",
data:{},
dataType:"json",
success:function (data) {
$(data).each(function(i,item)
{
var index = id++;
var bookId = item.bookId;
var bookName = item.bookName;
var author = item.author;
//判断是否为空出现undefined;
var translator = (item.translator==undefined ?"":item.translator);
var ISBN = item.ISBN;
var press = item.press;
var page = item.page;
var bookCase = item.bookCase;
var totalNum = item.totalNum;
var stock = item.stock;
var borrowNum = item.borrowNum;
var typeName = item.typeName;
var str = 'tr> ' + 'td>' + index +
'/td>' + 'td>' + bookId +
'/td>' + 'td>' +bookName +
'/td>' + 'td>' + author+
'/td>' +'td>'+translator+
'/td>' +'td>'+ISBN+
'/td>' +'td>'+press+
'/td>' +'td>'+page+
'/td>' +'td>'+bookCase+
'/td>' +'td>'+totalNum+
'/td>' +'td>'+stock+
'/td>' +'td>'+borrowNum+
'/td>' +'td>'+typeName+
'/td>/tr>';
$("#rankTable tbody").append(str);
str = "";
})
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("系统异常,请稍后重试!");
alert(XMLHttpRequest.status);
alert(XMLHttpRequest.readyState);
alert(textStatus);
}
})
});