html:
<table class="table table-hover center" id="table">
<thead>
<tr class="center">
<th class="col-xs-3 center">名称</th>
<th class="col-xs-3 center">创建时间</th>
<th class="col-xs-3 center">扫码时间</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
js:
$.ajax({
type: "get",url:'http://xxxxxxxx/show',
data:{ },
dataType: "json",
success: function (Json) {
console.log(Json);
var obj = eval(Json);
// 删除原有的内容
$("#table tbody tr").remove();
//循环遍历表格
for (var i = 0; i <obj.length-1; i++) {
var name = obj[i].name;
var createtime=obj[i].createtime;
var scantime=obj[i].scantime;
var $tr = $("<tr>"+
"<td>"+name+"</td>"+
"<td>"+openid+"</td>"+
"<td>"+createtime+"</td>"+
"<td>"+scantime+"</td>"
+"</tr>");
var $table = $("#table");
$table.append($tr);
}
},
error: function () {
// alert("加载失败");
}
});