1. 程式人生 > >ajax提交返回資料後的迴圈輸出

ajax提交返回資料後的迴圈輸出

$.ajax({
                    type:'post',
                    url:'/index.php/Mobile/Index/search_activity',
                    data:{date:date},
                    dataType:'json',
                    success:function(res){
                        if (res.status==200) {
                            var html='';
                            $.each(res.data.activity,function(index,item){
                                  html+='<div class="boatLi df hao" toLocation="/index.php/Mobile/Goods/boatDetail?id='+item.goods_id+'">';
                                  html+='<div class="img"><img src="'+item.original_img+'" alt="" /></div>';
                                  html+='<div class="flex cont"><div class="name ov-d">'+item.goods_name+'</div>';
                                  html+='<div class="price">'+item.shop_price+' /人</div>';
                                  html+='<div class="info df hao jcb">'+item.num+'人成團(已報7人)</div></div></div>';
                              })
                              $('.boatList').html(html);
                        }
                    }
                });