text: Q:
  
  Ajax Chat System sends XHR Finished Loading in console every second
  
  I have a problem with my chat system on my website. It keeps sending XHR Finished loading in the console. I know that i can disable it in chrome but other users who are using the site should not need to go through that process. It sends the message every one second as you see in setinterval and i want it to only send it when something in database has been added/deleted/changed
  I link my js here:
  function ajax() {
    var req = new XMLHttpRequest();
  
    req.onreadystatechange = function() {
      if(req.readyState == 4 && req.status == 200) {
        document.getElementById('chatbox').innerHTML =  req.responseText;
      }
    }
  
    req.open('GET', 'includes/chatbox.php', true);
    req.send();
  }
  setInterval(function(){ajax()},1000);
  
  That should be the only thing that needs to be edited but let me know if you need to see the php code or html code too.
  
  A:
  
  UPDATE: Interwebs suggests people seeing that XHR Finished loading are just you and those who are logging ajax requests. Uncheck Log XMLHttpRequests in the console's context menu. See here. Don't worry; it doesn't impact user experience at all for your users: logging of ajax requests is disabled by default so 99% of users won't actually log it, the console is hidden by default and the cost of a console.log is insignificant even on a Pentium machine from the 1990s. 
  Even if you would disagree, actually all you can do is worry; if Facebook can't stop those logs from showing up, neither can you :) You're fine.
  
  Not sure what you mean, but try this; maybe it will make your problem more evident and you can ask better:
  server.php
  <?php
  header("Access-Control-Allow-Origin: *");
  echo "hi!";
  
  client.html
  <!DOCTYPE html>
  <html>
      <head>
          <title></title>
      </head>
      <body>
          <div id='chatbox'></div>
          <script>
              function ajax() {
                var req = new XMLHttpRequest();
  
                req.onreadystatechange = function() {
                  if(req.readyState == 4 && req.status == 200) {
                    document.getElementById('chatbox').innerHTML = req.responseText;
                  }
                }
  
                req.open('GET', 'http://localhost:1234/', true);
                req.send();
              }
              setInterval(function(){ajax()},1000);
          </script>
      </body>
  </html>
  
  Run the server with
  php -S localhost:1234 server.php
  
  Open client.html on your browser and see if your problem is still happening.
  
  Some ideas:
  
  When you say "It keeps sending XHR Finished loading in the console", do you mean "in the networking tab"? If so, there's nothing you can do; if you send a request every second, it will appear there every second.
  The client-side (html code) doesn't know about the DB state change, so that's why you are polling every second. If instead, you want the server-side (php code) to tell you when the DB state changes, you need to use some form of WebSockets. PHP is not ideal for that, but you can try something like Ratchet.
  
  