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

json返回数据拼接HTML

时间:2015-02-12 15:32:58      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:

 <div class="box-lists">  </div>

 $.ajax({                

url: ‘AjaxPage/AjaxHandler.ashx‘,                

type: ‘POST‘,                

data: ‘ajaxType=pagelist&pageSize=12&pageIndex=1‘,                

dataType: "jsonp",                

cache: !0,                

jsonpCallback: "define",                

async: false,                

timeout: 5e3,                

error: function () { },                

success: function (obj) {                    

result1 = eval(obj)[0];                    

result2 = eval(obj).splice(1, obj.length);                    

//有数据                    

if (result1.allNum > 0) {                        

$("#allNum").html(result1.allNum);                    

}                    

if (result2 != null && result2 != "") {                        

var temp = ‘‘;                        

for (var i = 0; i < result2.length; i++) {                            

temp = temp + "<div class=‘more-box‘><div class=‘box-img‘><img src=‘" + result2[i].ImgPath + "‘ alt=‘‘ width=‘233‘ height=‘142‘></div><div class=‘box-text‘><div class=‘f-fl‘><p class=‘box-text-t‘>" + result2[i].Title + "</p><p>设计价 : <span class=‘color1‘>" + result2[i].Price + "</span>元</p></div><a href=‘" + result2[i].Url + "‘ target=‘_blank‘ class=‘f-fr‘>提交设计</a></div></div>";

                        }                        

$(".box-lists").html(temp);                    

}                

}            

});

        });

json返回数据拼接HTML

标签:

原文地址:http://www.cnblogs.com/rukialu/p/4287876.html

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