success:function(data){
alert("success");
//document.getElementById("outtable").innerHTML="<h1>success</h1>";
document.getElementById("outtable").innerHTML=
"<table class='table1'>"+
"<tr>"+
"<c:forEach items='${title}' var='ti'>"+
"<td>${ti}</td>"+
"</c:forEach>"+
"<td>操作</td>"+
"</tr>"+
"<c:forEach items=${empList1} var='list'>"+
"<tr>"+
"<td>${list.id}</td>"+
"<td>${list.deptId}</td>"+
"<td>${list.empName}</td>"+
"<td>${list.empMobile}</td>"+
"<td><input type='checkbox'>"+
"<button id='update'>修改</button>"+
"<button id='delete'>刪除</button>"+
"<button id='add'>增加</button>"+
"</td>"+
"</tr>"+
"</c:forEach>"+
"</table>"
}
想写一个foreach循环,但是除了<table><tr><tr>标签其他的都没有生效,
怎么写?
什么鬼 ? 循环的话 你可以用jstl 标签啊
你那个list应该在服务器返回
你这个样写都不要ajax了,直接做个函数,需要的地方调用就行
你判断过responseBody中的list有值,一般使用是不是要先进行/c:if;
而且你这样在js中拼接,为什么不采用传递对象map到页面,不采用$.ajax而是单纯的requestMapping(value="")来进行呢。
就如楼上所说的,你的items="${empList1}"可是没有引号的呀