JSON data populates the page table

    The data returned to the ajax in the background:

[{"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}]

 

    Front page:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
</head>

<body>
  <table id="myTable" cellpadding="1" cellspacing="0" border="1">
    <caption align="top">
      流程管理
    </caption>

    <thead>
      <tr>
        <th>流程ID</th>
        <th>流程名称</th>     </thead>       </tr>         <th>Action</th>
        <th>Process Version</th>


    <tbody></tbody>
  </table>
</body>
</html>

 

    Front-end js code: (the ajax used here is returned to the front-end json and processed):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
$(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.getAttribu te("username") %>">发起流程</a></td>');
                tbody.append(tr);
            });
            $('#myTable tbody').replaceWith(tbody);
        }
    });
});

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326542401&siteId=291194637