<script type="text/javascript">
$.post("${ctx}/plan/queryPlan.do",{},function(data) {
$.each(data.planList, function(index, content)
{
$("#plan_content").append("<a href='#'>" + content.plan_content +"</a>");
});
})
});
</script>
<div class="high">
<div class="timeline-content">
<span id="plan_content" name="plan_content"><a href="#">将数据显示在这里</a></span>
</div>
</div>
因为planList中有多条数据,我想在页面中全部显示,可是上面代码只能显示第一条数据,这是为什么?
你确认返回多条数据?
$.post("${ctx}/plan/queryPlan.do",{},function(data) {alert(data.planList.length)//加这个看输出多少
$("#plan_content").append("<a href='#'>" + content.plan_content +"</a> "); 超链接别连起来,加上
从表面上看的话没看出什么问题,不过按照你的问题描述来看的话,应该是each方法的问题,实在不行改成for循环试试。