How to make AJAX update automatically?
How to make AJAX update automatically?
I'm going to guess this is an easy thing to solve, but I've been reading docs and not finding much info on it. I'm currently using AJAX to get the information from a table. I saw in the docs it says it will push updates as soon as it gets them, however when the main server changes values, the table doesn't seem to change. This is my code currently:
$('#skins').DataTable({
"order": [[1, "asc"]],
"pageLength": 25,
ajax: {
"url": ...,
"dataSrc": "response.data"
},
columns: [
{
"orderSequence": [],
"render": function (data, type, row, meta) {
return "<a href='shop.php?view=details.php&id=" + row.skin_id + "' class='_zoom-animation'><img src='./skins/thumb/" + row.img + ".jpg' class='img-circle _20x20'><span><img src='./skins/thumb/" + row.img + ".jpg' class='img-circle'></span></a>";
}
}, {
"render": function (data, type, row, meta) {
var skinColor = valToColor(row.type);
return "<b class='" + skinColor + "'>" + row.name + "</b>";
}
}, {
"data": "collection"
}, {
"render": function (data, type, row, meta) {
var skinColor = valToColor(row.type);
return "<input type='checkbox' class='checkbox' name='" + row.id + "'>";
}
}
]
});
Am I missing some sort of refresh counter or something? If there is already one, how can I make it faster, lets say refresh every 3 - 5 seconds? (I am hoping this to be done without having the table say loading while it's refreshing!)
Answers
Nevermind I'm bad at looking. Completely overlooked https://datatables.net/reference/api/ajax.reload(). This with the callback worked great!
Mods can close this now