0

How do I make my list update in real time with jquery but without loads of request?

function startInterval() {
    checkInt = setInterval(function() {
        $("#queueOrderList").load("updateQueueList.php function() {
            console.log("Load was performed");
        });
    }, 100)
}

This is my code and it makes 10 requests per second.

V. Alen
  • 88
  • 8
  • 7
    Websockets, server-sent events, long polling, etc. – Phix Sep 27 '17 at 18:58
  • Use javascript `throttling` or `debounce` function, which fires event once in a certain period - https://remysharp.com/2010/07/21/throttling-function-calls. – lubosdz Sep 27 '17 at 18:59
  • This is already a `setInterval`, so throttling or debounce would be equivalent to just setting a longer interval. – Daniel Beck Sep 27 '17 at 19:01
  • your syntax is wrong, if you fix it your load function will execute every 100 miliseconds, so tell me what exacly do you want? – Okan Aslankan Sep 27 '17 at 19:21
  • @lubosdz He said real time. Your solution is better than his, but it does not fulfill that requirement. – The Muffin Man Sep 27 '17 at 20:00
  • @Phix are websockets for chat only? I basically need function that will call the other php file all the time, every 100ms as I wrote in my code, it works what it needs but the problem is that when I open developer tools and open network tab there is like thousands of requests. – V. Alen Sep 27 '17 at 20:44
  • 1
    Websockets are for anything real time. – Phix Sep 27 '17 at 20:57
  • Websockets are nice solution but not really consistently supported, particularly in IE. See compatability -https://stackoverflow.com/questions/1253683/what-browsers-support-html5-websocket-api and https://en.wikipedia.org/wiki/WebSocket . – lubosdz Sep 28 '17 at 07:26

0 Answers0