title: Automatic refresh a div tag when something inserted into a database
body: <p>I created a PHP page that select from the database <code>names</code> and created html page that contains Javascript code to refresh a div tag from the php page every 5 seconds automatic here s the code</p>
  
  <pre><code>&lt;script&gt;
  function Ajax(){
  var xmlHttp;
      try{    
          xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
      }
      catch (e){
          try{
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
          }
          catch (e){
              try{
                  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
              catch (e){
                  alert("No AJAX!?");
                  return false;
              }
          }
      }
  
  xmlHttp.onreadystatechange=function(){
      if(xmlHttp.readyState==4){
          document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
          setTimeout('Ajax()',1);
      }
  }
  xmlHttp.open("GET","select.php",true);
  xmlHttp.send(null);
  }
  
  window.onload=function(){
     setTimeout('Ajax()',2000);
  }
  &lt;/script&gt;
  &lt;div id="ReloadThis"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>so this is awesome, but I need to refresh only when something new inserted in to the database.
  So is there is a way to do that?</p>