问题描述
- 怎么将后台多条数据显示在页面上
-
<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循环试试。
时间: 2024-09-17 04:20:12