Alternative to constant AJAX requests for live tables?
Alternative to constant AJAX requests for live tables?
Bluestone
Posts: 9Questions: 3Answers: 0
Currently I'm sending an AJAX request every 1 second to keep my tables updated, however due to the amount of the requests, the browser begins to lag after a half hour or so.
Are there any alternatives to keep my tables live, but without filling up the memory?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Is it due to the amount of requests, only, or are you pulling back more and more data? Have you tried clearing your table at set increments of time, https://datatables.net/reference/api/clear(). If this doesn't help you might want to look at destroy(), although this method is usually reserved for cases when you change/update your options.
John
I'd suggest using a web-socket rather than constantly requesting data from the server. However, you should be able to use constant polling, and as far as I am aware there are no memory leaks in DataTables at the moment. We'd need a link to a test page showing the issue to be able to check that.
Allan
Hi Allan,
Is there an example that I can refer to for DataTable with web-socket. I have the same requirement to create a live table.
Thanks
No sorry. However, in essence all you would need to do is use the API methods to update the table as the data comes in - for example
row.add()
,cell().data()
androw().remove()
.Allan
Thanks.