I cant find a way to refresh that table like avery 10 seconds ...
I cant find a way to refresh that table like avery 10 seconds ...
simondatas
Posts: 4Questions: 3Answers: 0
Hello,
I have this code which works very well. Now I would like to refresh the datatable with my api every 10 seconds but is has been hours and I cant make it work ...
Any hep would be appreciated.
Many thanks
SImon
<script>
$(document).ready(function(){
var myPath = window.location.href;
console.log(myPath);
var newDatas = null;
var table = null;
$.ajax({
type: "GET",
url: myPath+"/refresh",
success: function(data) {
console.log("wow");
newDatas = JSON.parse(data);
console.log(newDatas);
table = $('#myTable').DataTable({
data: newDatas,
columns:[
{data : "lang"},
{data : "source"},
{data : "author.screen_name"},
{data : "author.description"},
{data : "full_text"},
{data : "created_at"},
{data : "author.location"},
{data : "author.followers_count"},
{data : "author.verified"},
{data : "author.name"}
]
});
}
})
});
</script>
This discussion has been closed.
Answers
This works :
'''javascript
$(document).ready(function(){
});
'''
Yup - a
setInterval
which callsajax.reload()
would be the way to do this.Allan