DataTable not refreshing with new data
DataTable not refreshing with new data
btm
Posts: 3Questions: 0Answers: 0
Hi All,
Could use some help.. tried all methods suggested online but cannot make it to work.
After an AJax call, The HTML table is refreshed, but I lose my pagination, sorting and search capabilities from the datatable.
this is my JS code inclusive of the Ajax Call:
<
script>
$(document).ready(function(){
$('#order_table').dataTable();
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#from_date").datepicker();
});
$('#filter').click(function(){
var from_date = $('#from_date').val();
if(from_date != '' )
{
$.ajax({
url:"fcheckin.php",
method:"POST",
data:{from_date:from_date},
success:function(data)
{
$('#order_table').DataTable().destroy();
$('#order_table').dataTable();
$('#order_table').html(data);
}
});
}
else
{
alert("Please Select Date");
}
});
});
This discussion has been closed.
Replies
your data is fully formed html rows, not JSON?
if it is, reverse DataTable() and HTML() lines
It is fully formed html , I will try the approach, and will let you know!
It worked!!!!
Thanks a lot!