ajax 循環追加HTML


 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 })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM