今天完成了首页文章的加载,使用了ajax请求,在页面初始化完成时发送ajax请求,完成首页文章加载
<script type="text/javascript">
$(function () {
$.ajax({
type: 'POST',
url: "${pageContext.request.contextPath}/index",
dataType: "json",//期待返回的数据类型
success: function (data) {
//alert("success:"+data.list[0].title);
$.each(data.list, function (i, n) {
$("#id" + i.toString()).html(n.title)
$("#classify" + i.toString()).html(n.classify)
$("#time" + i.toString()).html(n.update_time)
$("#type" + i.toString()).html(n.type)
$("#summary" + i.toString()).html(n.summary)
});
},
error: function (data) {
alert("error" + data);
}
});
});
</script>
对首页进一步美化
美化后效果图