title: Ajax call slows down and crashes browser
body: <p>I have a chat application that uses ajax to get messages from database as below:</p>
  
  <pre><code>    setInterval(function () {
        $.ajax({
            type: "GET",
            url: "chat.php",
            dataType: "json",
            success: function (response) {
                $(".chat").html(response);
                if (response !== lastResponse) {
                    var audio = new Audio('audio/vibes.mp3')
                    audio.play()
                }
                lastResponse = response
            }
        });
    }, 5000);
  </code></pre>
  
  <p>I am sure the reason is because it calls every 5 seconds. Please is there a fix for this using ajax such that it doesn't slow down the browser?</p>
  
  <p><strong>Note</strong>: I heard of web-sockets recently and planning to improve the chat app with web-sockets.</p>
  
  <p>I just need a quick fix for now. Thanks in advance.</p>