加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax动态加载页面(分页)

发布时间:2020-12-16 01:49:59 所属栏目:百科 来源:网络整理
导读:ajax请求控制层返回的 页面append 到相应的 标签中 。 @RequestMapping("/ajaxFindProjectByCodition") public String ajaxFindProjectByCodition(@RequestParam(value="projectIndustry",defaultValue="-1") Integer projectIndustry, @RequestParam(value=

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"..........

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读