ajax请求控制层返回的页面append到相应的标签中。
@RequestMapping("/ajaxFindProjectByCodition")
public String ajaxFindProjectByCodition(@RequestParam(value="projectIndustry",defaultValue="-1") Integer projectIndustry,
@RequestParam(value="projectStatus",defaultValue="-1") Integer projectStatus,@RequestParam(value="orderType",defaultValue="-1") Integer orderType,
@RequestParam(value="currentPage",defaultValue= "1") Integer currentPage,Model model,HttpServletRequest request) throws UnsupportedEncodingException{
//关键字
String key=request.getParameter("key");
if(!StringUtil.isEmpty(key)){
key=URLDecoder.decode(key,"utf-8");
}
List raiseProjectList = projectService.findProjectListByCondition(RAISETYPE_AWARD,projectIndustry,projectStatus,orderType,currentPage,PAGE_SIZE,key);
model.addAttribute("raiseProjectList", raiseProjectList);
return "/client/ajaxIndustryList"; //返回一个页面
}
ajaxIndustryList.jsp
已完成
${raiseProject.name }
${raiseProject.projectIntro }
已支持${raiseProject.supporterNum }人
js
var currentPage = 1;
function getData() {// 分类,状态,排序
currentPage++;
var projectIndustry = $("#projectIndustry").val();
var projectStatus = $("#projectStatus").val();
var orderType = $("#orderType").val();
var key = $("#key").val();
$.ajax({
type : 'post',
url : '../client/ajaxFindProjectByCodition',
data : {
'projectIndustry' : projectIndustry,
'projectStatus' : projectStatus,
'orderType' : orderType,
"currentPage" : currentPage,
key : key
},
success : function(result) {
if (result == "" || result == null || result.length < 15) {
// $("#addMore").hide();
$("#addMore").html("已经是最后一页");
}
$('#selectDataId').append(result);//
增加返回的页面
}
});
}