Alternative to constant AJAX requests for live tables?

Alternative to constant AJAX requests for live tables?

BluestoneBluestone 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

Answers

  • johnvndnbrkjohnvndnbrk Posts: 8Questions: 1Answers: 1

    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

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    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

  • devksdevks Posts: 10Questions: 0Answers: 0

    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

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    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() and row().remove().

    Allan

  • devksdevks Posts: 10Questions: 0Answers: 0

    Thanks.

This discussion has been closed.