ajax.reload() won't work
ajax.reload() won't work
JoeJoeJoe
Posts: 50Questions: 13Answers: 1
I'm trying to do two things.
1.I want ajax to reload the table every 30 seconds
2.I want a button that I can press and it will ajax reload the table.
Problems:
1. I'm getting a "can't reinitialize datatable etc..." error, tried it without putting it inside a function too.
$(function () {
var table = $('#ex').DataTable({
ajax: "data.json"
});
setInterval(function () {
table.ajax.reload(null, false); // user paging is not reset on reload
}, 3000);
})
I'm getting an invalid JSON response (tn/1) error on my code for the button:
<button id="refresh" class="fas fa-sync-alt fa-lg" style="text-align:right;color:white" type="button"></button> $("#refresh").click(function () { var table = $('#WTM_LOG').DataTable(); table.ajax.reload(); })
Any help would be appreciated. Thanks.
This discussion has been closed.
Answers
Your code snippet works here:
http://live.datatables.net/zunaxupu/1/edit
Something else must be causing the error. Can you post a link to your page or up my example to replicate the issue?
Follow the troubleshooting steps in the link provided in the URL. It will show you how to see the response then troubleshooting steps can be taken from there.
Kevin