<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><linkrel="stylesheet"type="text/css"href="css/datatables.css"/></head><body><divclass="box"><tableid="datatable"><caption>用户信息管理表</caption></table></div><divclass="demo"></div><BUTTONtype="button"id="btn"> 测试</BUTTON></body></html><scriptsrc="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script><scriptsrc="../static/js/datatable.js"type="text/javascript"></script><scripttype="text/javascript">
url ='http://127.0.0.1:8000/'$('#btn').click(function(){
html =''//ajax请求
$.get(url,function(res){
console.log(res.data);
html +='<table border="1px">';
html +='<thead><th>用户名</th>';
html +='<th>用户密码</th>';
html +='<th>操作</th>';
html +='</thead><tbody>';var len = res.data.length;for(var i =0; i < len; i++){
html +='<tr><td>'+ res.data[i][1]+'</td>';
html+='<td>'+ res.data[i][2]+'</td>';
html+='<td><button id="edit" οnclick="alert(2)">修改</button></td>';
html+='</tr>';}
html +='</table>';$('.demo').append(html);})})</script>