gpt4 book ai didi

javascript - jquery 数据表中第 0 行请求未知参数 1

转载 作者:行者123 更新时间:2023-12-03 08:37:44 26 4
gpt4 key购买 nike

我有下面的代码用于在我的 spring mvc 项目中生成 jquery 数据表。但我加载页面时,JavaScript 抛出了一些警告。 enter image description here

 var sTable = $('#tblKeyDetails').dataTable({
"aoColumns" : [ null,null, null,null],
"sPaginationType" : "full_numbers",
});
$.ajax({
dataType : 'json',
type : 'GET',
url : 'getKeyDetails.html',
data :({
form : $('#ddlKeyStatus').val()
}),
beforeSend : function() {
//startPreloader();
},
complete : function() {
//stopPreloader();
},
success : function(data) {
sTable.fnClearTable();
$.each(data, function(index,item) {
var rowCount = index+1;
sTable.fnAddData( [ '<label align="center">'+rowCount+'</label>',
item['key'],
item['date'],
item['userEmail']
]);
});

}
});

响应对象包含

date: null
deviceId: null
id: 3
key: "DQAIYLFFDVFG"
userEmail: null
userId: 0

最佳答案

更改此:

sTable.fnAddData( [ '<label align="center">'+rowCount+'</label>',
item['key'],
item['date'],
item['userEmail']
]);

sTable.fnAddData( [ '<label align="center">'+rowCount+'</label>',
item['key']!=null ? item['key'] : "",
item['date']!=null ? item['date'] : "",
item['userEmail']!=null ? item['userEmail'] : ""
]);

防止空值将解决您的问题。您还可以禁用数据表警告消息,但解决问题可能会更好。

关于javascript - jquery 数据表中第 0 行请求未知参数 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33145169/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com