ajax的理解
2020-12-16 23:04
标签:tle produce map items ice mod result ping 获取 ajax的理解 标签:tle produce map items ice mod result ping 获取 原文地址:https://www.cnblogs.com/lanbao5339/p/14111466.html function fun_page(){
var url="${root}/book/page"; 获取一个地址
var data={"index":index,"size":size,"step":step}; 以键值对封装分页的参数:第几页,显示的行数,起始页
$.getJSON(url,data,function(result){ 到该地址(路由)去
$(result.items).each(function(){
var row=$(‘ tr>tr>‘);
row.append(‘td>‘+this.bid+‘td>‘);
row.append(‘td>‘+this.btitle+‘td>‘);
row.append(‘td>‘+this.bauthor+‘td>‘);
row.append(‘td>‘+this.bpublic+‘td>‘);
row.append(‘td>button class="btn text-primary btnupd" lang="‘+this.bid+‘" data-toggle="modal" data-target="#myModal">修改button>‘+
‘button class="btn text-primary btndel" lang="‘+this.bid+‘">删除button>td>‘);
row.appendTo($("#tblbook tbody"));
});
@ResponseBody
@RequestMapping(value="/book/page",method=RequestMethod.GET,
produces={"application/json;charset=utf-8"})
public String method1(@RequestParam(name="index",defaultValue="1")int index, 从封装的data里面获取
@RequestParam(name="size",defaultValue="1")int size,
@RequestParam(name="step",defaultValue="1")int step){
String json=JSONObject.toJSONString(bookService.getBookList(index, size, step, "")); 去数据库里面查询,以json的形式返回
return json;
}$(result.items).each(function(){ //这个items是分页实体类里的一个当前页数据List
var row=$(‘
‘); //然后一个个的赋值到html桌面
row.append(‘ ‘+this.bid+‘ ‘);
row.append(‘‘+this.btitle+‘ ‘);
row.append(‘‘+this.bauthor+‘ ‘);
row.append(‘‘+this.bpublic+‘ ‘);
row.append(‘
‘+
‘
‘);
row.appendTo($("#tblbook tbody"));
});
下一篇:netcore IIS部署发布