DataTable Reloading issue

Viewed 24

I really don't understand why my code is not reloading because when I use early it works fine but now it's always throw this error:

DataTables warning: table id=staff_rep - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

$(document).ready(function() {
  $('#staff_rep').DataTable({
    "paging": true,
    "lengthChange": true,
    "searching": true,
    "ordering": true,
    "info": true,
    "autoWidth": false,
  });
});

var usid;

$(document).on('click', '.del', function() {
  usid = $(this).attr('id');
  $('#confirmModal').modal('show');
});

$('#ok_button1').click(function() {
  $.ajax({
    url: "destroy/" + usid,
    beforeSend: function() {
      $('#ok_button1').text('Deleting...');
    },
    success: function(data) {
      // setTimeout(function() {
      //     $('#confirmModal').modal('hide');
      //     $('#ok_button1').text('Ok');
      //     $('#staff_rep').DataTable().ajax.reload();
      // }, 1000);
      if (data.type == 'success') {
        $('#confirmModal').modal('hide');
        $('#ok_button1').text('Ok');
        $('#staff_rep').DataTable().ajax.reload();
      }
    }
  })
});
0 Answers
Related