0

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();
 }
 }
 })
});
Rory McCrossan
338k41 gold badges322 silver badges353 bronze badges
asked Sep 13, 2022 at 13:32
3
  • The link in the error gives you full instructions on how to debug the issue - your JSON format doesn't match what's required by DataTables. Their documentation shows you the format you need to use: datatables.net/examples/ajax/objects.html Commented Sep 13, 2022 at 13:35
  • Show us the Controller's method source code meant to handle this request. This error usually happens when your backend throws an error while handling the request. Try clearing and inspecting your storage/logs/laravel.log file for any backend errors. Commented Sep 13, 2022 at 13:44
  • You seem to be missing the columns: [...] DataTable option. Commented Sep 13, 2022 at 13:47

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.