ajax 循环追加HTML
Posted 清清沁沁
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 })
以上是关于ajax 循环追加HTML的主要内容,如果未能解决你的问题,请参考以下文章