problem with data table when data is append with ajax,sorting and searching is not working....
problem with data table when data is append with ajax,sorting and searching is not working....
problem with data table when data is append with ajax,sorting and searching is not working....
function users() {
var table;
//reinitialise the dataTable
table = $('#sample_1').DataTable({
destroy: true,
bLengthChange: false,
paging: false,
});
$.ajax({
type: "POST",
url: "<?php echo base_url('admin/users'); ?>",
data: 'id='+id,
dataType: 'json',
cache: false,
success: function(data) {
if(data!='') {
var trdata="";
$.each(data, function(i, item) {
trdata+='<tr><td><img alt="User Pic" class="img" src="<?php echo base_url(); ?>assets/user_pics/'+data[i].user_pic+'" width="50px"></td><td>'+data[i].user_name+'</td><td>'+data[i].user_phone+'</td><td>'+data[i].user_email+'</td><td>'+data[i].avgvisits+'</td></tr>';
});
$('#display_customers').append(trdata);
} else {
trdata='<tr><td colspan="7"><h3>No customers are available</h3></td></tr>';
$('#display_customers').html(trdata);
}
table.Draw();
}
});
}
Answers
i got solutions of above post, i tried bellow code, it working fine..........., thanks you