用的datatable ajax获取数据源,行内的删除能执行成功 但是不管是delete还是update都不起作用,后台接口是通的,
```javascript
$(function () {
return $('.datatable').DataTable({
"language": {
"decimal": "",
"emptyTable": "表格无数据",
"info": "本页显示 _START_ 到 _END_ 项 共 _TOTAL_ 项数据",
"infoEmpty": "0 to 0 of 0",
"infoFiltered": "(filtered from _MAX_ total entries)",
"infoPostFix": "",
"thousands": ",",
"lengthMenu": "显示 _MENU_ 条/页",
"loadingRecords": "加载中...",
"processing": "请稍后",
"search": "搜索:",
"zeroRecords": "未找到相关记录",
"paginate": {
"first": "首页",
"last": "尾页",
"next": "下一页",
"previous": "上一页"
},
"aria": {
"sortAscending": ": 升序排列",
"sortDescending": ": 降序排列"
}
},
"ajax": {
"url": "http://localhost:8080/SmartOA/user/getall",
"dataType": "json",
"type": "POST",
"dataSrc": function (res) {
return res.list;
}
},
"columns": [
{"data": "id"},
{"data": "name"},
{"data": "email"},
{"data": "islogin"},
{"data": "createtime"},
{"data": "status"}
],
"fnInitComplete": function () {
$("#switch").bootstrapSwitch({
onText: "在线", // 设置ON文本
offText: "离线", // 设置OFF文本
onColor: "success",// 设置ON文本颜色(info/success/warning/danger/primary)
offColor: "warning", // 设置OFF文本颜色 (info/success/warning/danger/primary)
size: "normal", // 设置控件大小,从小到大 (mini/small/normal/large)
// 当开关状态改变时触发
onSwitchChange: function (event, state) {
if (state == true) {
console.log("true");
} else {
console.log("false");
}
}
});
},
"columnDefs": [{
"targets": -1,//操作按钮目标列
"data": null,
"render": function (data, type, row) {
var id = '"' + row.id + '"';
var name = '"' + row.name + '"';
var email = '"' + row.email + '"';
var
html = " + "'" + id + "'" + "," + "'" + name + "'" + "," + "'" + email + "'" + ") class='up btn btn-default btn-xs'> 编辑"
html += " + "'" + id + "'" + ") class='down btn btn-default btn-xs'> 删除"
return html;
}
},
{
"targets": -3,//操作按钮目标列
"data": null,
"render": function (data, type, row) {
var id = '"' + row.id + '"';
var
html = ""
return html;
}
}],
"dom": '<"top"fl<"clear">>rt<"bottom"ip<"clear">>',
});
});
function deluser(id) {
alert(id)
var basePath = $("#basePath").val();
$.ajax({
url: basePath + "user/deluser",
datatype: "json",
type: "Post",
data: {
id: id,
},
success: function (res) {
if (res.i=1) {
alert("chenggong1")
window.location.reload();
}
else {
alert("shibai")
}
},
error: function () {
}
})
}
```
这个你应该看下后台接口有没有真正删掉或者更新了这个数据
那你 刷新 页面后数据 是不是真的更新了 ? 如果是 ,那就不是 后端的问题