1、html
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="myresource/bootstrap/js/jquery-3.1.1.min.js"></script> <script type="text/javascript" src="list.js"></script> </head> <body> <table > <table id="td"> <tr> <td>编号</td> <td>姓名</td> <td>密码</td> </tr> </table> </table> </body> </html>
1 $.post( 2 "http://localhost:8080/list", 3 function(obj){ 4 5 for(var i in obj){ 6 $("#td").append("<tr><td>"+obj[i].sid+"</td><td>"+obj[i].sname+"</td><td>"+obj[i].pwd+"</td></tr>"); 7 } 8 9 },"json" 10 ); 11
3、浏览器访问 localhost:8080/静态资源