我已经发布了数组JSON。 我已经尝试了很多次,但是没有用。
//我将代码放到那里,请帮助我调试它。
字符串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}]}
这是数组中view元素的代码
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>
请帮助我解决此问题。非常感谢
===== 更新。 我需要每个循环内的更多details元素 将 datax 更改为 datax.resultUser
答案 0 :(得分:0)
在$ .each中将 data 更改为 datax.resultUser ,以遍历resultUser数组
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>
答案 1 :(得分:0)
df['ideal_weight'] = np.where(((df.fats > np.percentile(df.fats, 25)) & (df.fats < np.percentile(df.fats, 50))), 'yes', 'no')
data.resultUser仅数组,您只需对其进行迭代