码迷,mamicode.com
首页 > Web开发 > 详细

ajax 循环追加HTML

时间:2019-01-10 19:34:53      阅读:522      评论:0      收藏:0      [点我收藏+]

标签:code   pen   inf   href   style   item   content   get   type   

 1                         $(".iconfont").click(function(){
 2                                             page=$("input[name=‘count‘]").val();
 3                                             typeid=$("input[name=‘typeid‘]").val();                                            
 4                                             $.ajax({url:"index.php?mod=mobile&act=goods&type=ajax",
 5                                             type:‘GET‘,
 6                                             dataType:"json",
 7                                             data:{"page":page,"typeid":typeid},
 8                                             success:function(data){
 9                                                 if(data.state==1){                                                   
10                                                     tableContent="";
11                                                     $.each(data.msg,function(i){
12                                                         var commentInfo = data.msg[i];
13                                                         var num = i+1;
14                                                         tableContent += ‘<a href="javascript:;" class="aui-flex-links-item">‘;
15                                                         tableContent += ‘<div class="aui-flex-links-img">‘;
16                                                         tableContent += ‘<img src="‘+commentInfo.goods_thumb+‘">‘;
17                                                         tableContent += ‘</div>‘;
18                                                         tableContent += ‘<div class="aui-flex-links-text">‘+commentInfo.goods_name;
19                                                         tableContent += ‘<br>‘;    
20                                                         tableContent += ‘<span style="color:#ff5647">‘;    
21                                                         tableContent += ‘<i>¥</i>‘+commentInfo.shop_price;    
22                                                         tableContent += ‘</span></div>‘;    
23                                                         tableContent += ‘</a>‘;                                                      
24                                                     })
25                                                     $(".aui-flex-links").append(tableContent);
26                                                     $("input[name=‘count‘]").val(++page);
27                                                 }else{                                                   
28                                                     $("#show").append(data.msg);
29                                                     $(‘.iconfont‘).css("display","none")
30                                                 }
31                                             }
32                                         });
33                                     })

 

ajax 循环追加HTML

标签:code   pen   inf   href   style   item   content   get   type   

原文地址:https://www.cnblogs.com/ssx314/p/10251727.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!