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

Ajax异步请求,对map中的list集合进行遍历

发布时间:2020-12-16 00:59:29 所属栏目:百科 来源:网络整理
导读:resp为一个Map对象,包含有一个List集合,通过jQuery.each(resp.cmpList,function(i,item){ }对List集合进行遍历,resp.cmpList为一个list集合,item为list集合里的一个元素 $.ajax({url:'/data/query_media',cache: false,type:'post',data:paramStr,dataTyp

resp为一个Map对象,包含有一个List集合,通过jQuery.each(resp.cmpList,function(i,item){}对List集合进行遍历,resp.cmpList为一个list集合,item为list集合里的一个元素

$.ajax(
	{
		url:'/data/query_media',cache: false,type:'post',data:paramStr,dataType:'json',async:false,success:function(resp)
		{
			$("#con_one_2").children().hide();
			$("#con_one_2").append("<div id='media_"+resp.pageIndex+"'></div>")
			//$("#con_one_2").empty();
			//遍历公司集合,拼接显示公司列表
			 jQuery.each(resp.proList,item){  
			 	 $("#media_"+resp.pageIndex).append("<div class="ttkx">"+
            	 "<div class="tp"><div><a href="/get_media_info.html?id="+item.id+""><img src=""+item.cover+"" width='114' height='90' /></a></div></div> "+
             	 " <div class="tp_z">"+
            	 "  <p><b>简介:</b>"+ checkNull(item.productExplain)+"</p>"+
             	 " <p><b>价格:</b>"+ price(checkNull(item.productPrice))+"</p>"+
            	 "  <p><b>类型:</b>"+ checkNull(item.productType)+"</p>"+
            	 "  <p><b>公司:</b><a href='/get_company_info.html?cmpId="+item.cmpId+"'>"+ item.cmpName+"</a></p>"+
           		 " </div>"+
          		 "</div>");
              
            }); 
            //设置分页
            var page1 = "";
            var page2 = "";
            var next = parseInt(resp.pageIndex)+1;
            var pre = parseInt(resp.pageIndex)-1
            if(resp.pageIndex>1)
            {
            	page1 = "<td><a onclick='nextPageMedia("+pre+");'><img src="/images/Previous_page.jpg" width="59" height="25" style='cursor:pointer'/></a></td>";
            }else{
            	page1 = "<td><img src="/images/Previous_page.jpg" width="59" height="25" /></td>"
            }
             if(parseInt(resp.pageIndex) < parseInt(resp.maxPage))
            {
            	page2 = "<td><a onclick='nextPageMedia("+next+");'><img src="/images/next_page.jpg" width="59" height="25" style='cursor:pointer'/></a></td>";
            }else{
            	page2 = "<td><img src="/images/next_page.jpg" width="59" height="25" /></td>"
            }
            
            $("#media_"+resp.pageIndex).append("<table cellpadding="0" cellspacing="0" id="page">"+
            "<tr>"+
            "<td >&nbsp;</td>"+
            page1+
             "<td >&nbsp;"+resp.pageIndex+"/"+resp.maxPage+"</td>"+
           page2+
            "</tr>"+
            "</table>");	
		}
	});

(编辑:李大同)

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

    推荐文章
      热点阅读