ajax动态加载页面(分页)

前端之家收集整理的这篇文章主要介绍了ajax动态加载页面(分页)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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<RaiseProject> raiseProjectList = projectService.findProjectListByCondition(RAISETYPE_AWARD,projectIndustry,projectStatus,orderType,currentPage,PAGE_SIZE,key);
model.addAttribute("raiseProjectList",raiseProjectList);
return "/client/ajaxIndustryList"; //返回一个页面

}


ajaxIndustryList.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:forEach items="${raiseProjectList }" var="raiseProject" varStatus="stat">
<div id="showDel${stat.count }" class="item clearfix bottom go" data-id="a6a97c2f7d25963bd680ebb9" data-url="/deal/id-137125">
<a href="../clientUser/cancelCareProject?projectId=${raiseProject.id }" class="delete" ></a>
<a href="../client/gotoProjectDetail?projectId=${raiseProject.id }" class="a-click"></a>
<div class="item-image uc">
<a><img src="${raiseProject.coverImgUrl }"></a>
<p class="bar"><span style="width:<fmt:formatNumber value='${raiseProject.isFinishPercent }' type='percent' maxIntegerDigits='8'/>;">
</span></p>
<em>已完成<fmt:formatNumber value="${raiseProject.isFinishPercent }" type="percent" maxIntegerDigits="8"/></em>
</div>
<div class="item-content uc">
<h3><a>${raiseProject.name }</a></h3>
<p class="p-color">${raiseProject.projectIntro }</p>
<div class="clearfix bottom"><div class="price"><em class="number">${raiseProject.minMoney }</em><span><em>元</em>起</span></div>
<span class="support">已支持<em>${raiseProject.supporterNum }</em>人</span>
</div>
</div>
</div>
</c:forEach>

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);// 增加返回的页面
}
});

}


<section class="bg-white border-tb items" id="selectDataId"> <c:forEach items="${raiseProjectList}" var="raiseProject"..........

猜你在找的Ajax相关文章