我一直在尝试使用axaj调用的结果填充响应数据表。但是,当我提交请求时,我收到的空白页面只有响应实体。
这是我在api完成工作后检索到的bean:
private String validator;
private String validThrough;
private String creator;
private String createdOn;
private String profile;
private String token;
private String profileType;
private String status;
这是我的ajax调用:
$(document).ready(function () {
var form = $('.smart-form');
var counter = 0;
form.submit(function (e) {
if (counter != 0) {
$("#datatable_col_reorder").dataTable().fnDestroy();
counter++;
}
e.preventDefault();
$.ajax ( {
url: form.attr('action'), dataSrc: "", "data": {
"validator": $('#searchValidator').val(),
"validFrom": $('#searchValidFrom').val(),
"validTo": $('#searchValidTo').val(),
"creator": $('#searchCreator').val()
"createdOn": $('#searchCreatedOn').val()
"profile": $('#searchProfile').val()
"token": $('#searchToken').val()
"profileType": $('#searchSelectType').val()
},
success: function (data)
{
jQuery.noConflict();
var table =$('#datatable_col_reorder').DataTable ( {
data:data,
columns: [
{"data": "validator"},
{"data": "validThrough"},
{"data": "creator"},
{"data": "createdOn"},
{"data": "profile"},
{"data": "token"},
{"data": "profileType"},
{"data": "status"}
],
bDestroy: true
});
}
});
});
});
我刚收到这个:
[{"validator":"ЧъкНорис","validThrough":"2019-06-09 12:55:48.0-2019-06-09 12:55:48.0","creator":"ЧъкНорис","createdOn":"2019-06-09 12:55:48.0","profile":"ProfileAlumni","token":"QWERTYUI","profileType":"1","status":"Inactive"},{"validator":"ЧъкНорис","validThrough":"2019-06-09 12:55:48.0-2019-06-09 12:55:48.0","creator":"ЧъкНорис","createdOn":"2019-06-09 12:55:48.0","profile":"ProfileAlumni","token":"QWERTYUI","profileType":"1","status":"Inactive"}]
我的页面消失了,我只有响应,这不是我正在寻找的行为。 我已经检查了响应的名称是否与表格列相同,但这不是问题。
我检查了所有选择器,认为它们都是正确的:
<table id="datatable_col_reorder"
class="table table-striped table-bordered table-hover"
width="100%">
<thead>
<tr>
<th>validator</th>
<th>validThrough</th>
<th>creator</th>
<th>createdOn</th>
<th>profile</th>
<th>token</th>
<th>profileType</th>
<th>status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
答案 0 :(得分:0)
我已经解决了我的问题,问题是我在选择数据后错过了冒号:
"validator": $('#searchValidator').val(),
"validFrom": $('#searchValidFrom').val(),
"validTo": $('#searchValidTo').val(),
"creator": $('#searchCreator').val() <---- should be a colon
"createdOn": $('#searchCreatedOn').val() <---- should be a colon
"profile": $('#searchProfile').val() <---- should be a colon
"token": $('#searchToken').val() <---- should be a colon
"profileType": $('#searchSelectType').val()