获取数据库内容一

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ajax获取集合</title>
<script src="../js/jquery-3.1.1.min.js"></script>
</head>
<body>
<table>
<thead>
<th>id</th>

<th>birthday</th>
</thead>
<tbody ></tbody>
</table>
<script>
$(function () {
$.get("http://localhost:8080/jquery/servlet/OneServlet",function (data) {
console.log(data);
var num = eval(data);
var str;
for (var i=0;i<num.length;i++){
str +="<tr><td>" + num[i].id+"</td><td>" +num[i].birthday+"</td></tr>";
$("tbody").html(str);

}
})
})
</script>
</body>
</html>
posted @ 2017-02-14 16:19  iriliguo  阅读(336)  评论(0编辑  收藏  举报