json返回数据拼接HTML
2015-02-12 14:02 rukialu 阅读(2251) 评论(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);
}
}
});
});