[英]datatable is displaying old value when i click next or previous button.
im using jquery datatable for displaying data based on user search using ajax. 即时通讯使用jquery数据表基于使用ajax的用户搜索显示数据。 the datatable is not refreshing.
数据表未刷新。 it is displaying first time loaded value when i click next or previous button.
当我单击下一个或上一个按钮时,它显示的是第一次加载的值。
function searchCustomer() {
var frm = $("#customerDetailSearchForm").serializeObject();
$("#tbl_contact_search_result").hide();
$.ajax({
type: 'POST',
url: restContextPath + '/IONSWeb/rest/order/searchContact',
data: JSON.stringify(frm),
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function(data, status, xhr) {
$("#tbl_contact_search_result tbody").empty();
$.each(data.body, function(i, item) {
var checkBox = item.actionString;
var dataTableBodyHTML = '<tr><td>'+ checkBox + '</td><td>'+ item.name + '</td><td>'+ item.street +'</td><td>' + item.city + '</td><td>'+ item.state + '</td><td>' + item.phone +'</td></tr>';
$("#tbl_contact_search_result tbody").append(dataTableBodyHTML);
$("#tbl_contact_search_result").show();
});
var dataTable = $('#tbl_contact_search_result').DataTable();
},
error: function(jqXhr, textStatus, errorMessage) {
$('.ErrorMsg').html('<h5>An error has occurred</h5>');
}
});
}
Just disable the ajax caching feature. 只需禁用ajax缓存功能。 The default value is true .
默认值为true 。 So, you have to set it as false.
因此,您必须将其设置为false。 (cache: false)
(缓存:false)
function searchCustomer() {
var frm = $("#customerDetailSearchForm").serializeObject();
$("#tbl_contact_search_result").hide();
$.ajax({
type: 'POST',
url: restContextPath + '/IONSWeb/rest/order/searchContact',
data: JSON.stringify(frm),
dataType: 'json',
cache: false,
contentType: "application/json; charset=utf-8",
success: function(data, status, xhr) {
$("#tbl_contact_search_result tbody").empty();
$.each(data.body, function(i, item) {
var checkBox = item.actionString;
var dataTableBodyHTML = '<tr><td>'+ checkBox + '</td><td>'+ item.name + '</td><td>'+ item.street +'</td><td>' + item.city + '</td><td>'+ item.state + '</td><td>' + item.phone +'</td></tr>';
$("#tbl_contact_search_result tbody").append(dataTableBodyHTML);
$("#tbl_contact_search_result").show();
});
var dataTable = $('#tbl_contact_search_result').DataTable();
},
error: function(jqXhr, textStatus, errorMessage) {
$('.ErrorMsg').html('<h5>An error has occurred</h5>');
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.