南开小巷

导航

后台返回的json数据传到前端页面并在页面的表格中填充

web前端页面:

<table id="myTable" cellpadding="1" cellspacing="0" border="1">
<caption align="top">流程管理</caption>
<thead>
<tr>
<th>流程ID</th>
<th>流程名称</th>
<th>流程版本</th>
<th>操作</th>
</tr>
</thead>
<tbody></tbody>

</table>

从后台返回的json数据:

[{"deploymentId":"80001","id":"leave-16","name":"leave","version":16},{"deploymentId":"80015","id":"leave-17","name":"leave","version":17},{"deploymentId":"80022","id":"leave-18","name":"leave","version":18},{"deploymentId":"90001","id":"leave-19","name":"leave","version":19},{"deploymentId":"90012","id":"leave-20","name":"leave","version":20},{"deploymentId":"100001","id":"leave-21","name":"leave","version":21}]

前端的js代码:(这里用的ajax返回给前台的json并做处理)

$(function(){
$.ajax({
url:"/jbpm2web/jbpm/show?username=<%=session.getAttribute("username") %>",
type:"get",
success: function(data){
var obj=eval(data);
var tbody=$('<tbody></tbody>');
$(obj).each(function (index){
var val=obj[index];
var tr=$('<tr></tr>');
tr.append('<td>'+ val.id + '</td>' + '<td>'+ val.name + '</td>' +'<td>'+ val.version + '</td>' + '<td><a href="/jbpm2web/jbpm/delete?id='+val.deploymentId+'" >删除流程</a>|<a href="/jbpm2web/jbpm/start?id='+val.id+'&username=<%=session.getAttribute("username") %>">发起流程</a></td>');
tbody.append(tr);
});
$('#myTable tbody').replaceWith(tbody);
}
});
});

posted on 2016-06-16 14:27  南开小巷  阅读(28512)  评论(0编辑  收藏  举报