通过Jquery和Ajax初始化加载页面数据

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Android_Mrchen/article/details/83274056
<script src="static/js/jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
	$.ajax({
        type:"post",
        url:"product/alllist.do",
        dataType:'json',
        success:function(msg){
       	 console.log(msg);
       	 var newshtml="";
       	 for(i in msg.data.list){
       	    newshtml+='    <li class="floor-item">';
       	    newshtml+='        <a href="./list.html?categoryId=100016">';
       	    newshtml+='            <span class="floor-text">'+msg.data.list[i].subtitle+'</span>';
       	    newshtml+='            <img class="floor-img" src="'+msg.data.list[i].mainImage+' "/>';
       	    newshtml+='        </a></li> ';
       	 $("#alllist").append(newshtml);		 
       	 }
        },
        error:function(msg){
        console.log(msg);
        }
    });
	
});
</script>

猜你喜欢

转载自blog.csdn.net/Android_Mrchen/article/details/83274056