webveuje/js/demo/jqajax.html
2021-03-23 10:58:10 +08:00

39 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
<script>
$.ajax({
url:"http://127.0.0.1:5000/userlist",
type:"GET",
dataType:"json",
success:function(res){
console.log(res)
var uinfo=res
$.each(uinfo,function(i,val){
// console.log(i,val)
var obj=val
console.log(obj.username)
var list=$("<tr><td>"+obj.userid+"</td><td>"+obj.username+"</td><td>"+obj.account+"</td><td>"+obj.pwd+"</td></tr>")
$('#uinfo').append(list)
})
}
})
</script>
</head>
<body>
<table id="uinfo">
<tr>
<th>编号</th>
<th>姓名</th>
<th>账号</th>
<th>密码</th>
</tr>
</table>
</body>
</html>