success: function (data) {
if (data == null) {
return false;
}
var tbody=$("#tbody");
list = data.object;
$.each(list, function (index, value) {
var b="";
var energize;
var blackout;
if(value.energize==null){
energize="";
}
if(value.blackout==null){
blackout="";
}
b+="<tr>"
b+="<td class='id'>"+value.id+"</td>";
b+="<td class='orderid'>"+value.orderid+"</td>";
b+="<td class='type'>"+value.type+"</td>";
b+="<td class='power'>"+value.power+"</td>";
b+="<td class='num'>"+value.num+"</td>";
b+="<td class='energize'>"+energize+"</td>";
b+="<td class='blackout'>"+blackout+"</td>";
b+="<td class='createtime'>"+value.createtime+"</td>";
b+="<td><button type='button' class='btn btn-primary energize'>通电</button><button class='btn btn-primary blackout' >断电</button></td>"
b+="<td><button type='button' class='btn btn-primary update'>修改</button><button class='btn btn-primary del'>删除</button></td>"
b+="</tr>"
tbody.append(b);
})
},
这是遍历数据
然后
$(".energize").click(function () {
debugger;
var id=$("#id").val();
console.log("1")
$.ajax({
url: 'jh/order/energize',
type:"post",
contentType: "application/json",
dataType: "text",
data: { 'id':id},
success: function (data) {
if (data = null) {
return false;
}
window.location.reload();
console.log(data);
},
error: function (data) {
console.log(data)
}
})
这个方法触发不了