i have issued with array JSON. i have try many time but didn't work.
//i put my code to there, kindly help me debug it.
the string json
> {"resultUser":[{"username":"quyennv","email":"quyencl@hotmail.com","userlevel":0,"datecreate":"20/03/2019
> 12:00:00
> AM","status":1},{"username":"sample","email":"sameple@hotmail.com","userlevel":1,"datecreate":"20/03/2019
> 12:00:00 AM","status":1}]}
and here is code for view element in array
var datax = {"resultUser":[{"username":"quyennv","email":"quyencl@hotmail.com","userlevel":0,"datecreate":"20/03/2019 12:00:00 AM","status":1},{"username":"sample","email":"sameple@hotmail.com","userlevel":1,"datecreate":"20/03/2019 12:00:00 AM","status":1}]};
var userTbl = $('#listUser tbody').empty();
$.each(datax.resultUser,function (index) {
index += 1;
userTbl.append('<tr><td>' + this.username + '</td><td>'
+ this.email + '</td><td>' + this.userlevel + '</td><td>'
+ this.datecreate + '</td><td>' + this.status + '</td></tr>');
});
table,td{
border:1px solid #000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<table id="listUser">
<thead ><tr><td>Username</td><td>Email</td><td>User Level</td><td>Date Created</td><td>User status</td></tr></thead>
<tbody>
</tbody>
</table>
</body>
kindly help me solve this issue. thanks a lot
===== Updated. i need more details element inside the each loop change datax to datax.resultUser