title: How do I use ajax to auto refresh a section of page without manually invoking a function within javascript?
body: <p></p>
  
  <pre><code>var xmlhttp;
  
  //Set up ajax first so he knows which guy to play with
  function loadXMLDoc(url,cfunc)
  {
      //Code to catch modern browsers
      if (window.XMLHttpRequest)
      {
          xmlhttp=new XMLHttpRequest();
      }
  
      //Code to catch crap browsers
      else
      {
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
  
      //Set up
      xmlhttp.onreadystatechange=cfunc;
      xmlhttp.open("GET",url,true);
      xmlhttp.send();
  }
  
  //Set a function to deploy when something calls myFunction()
  function myFunction()
  {
      loadXMLDoc("../../../support/ajaxTest.txt",function()
      {
          //Fires off when button pressed
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
          {
              document.getElementById("statusRefresh").innerHTML=xmlhttp.responseText;
              setInterval( "alert('Hello I did something but i needed to be invoked by a button first')", 5000 );  
          }
  
      });
  }
  </code></pre>
  
  <p>I want to call restful java service to refresh a 'status'. I need ajax to auto refresh the this status once the page has been hit. The Refresh method isnt instantaneous, for it has to talk with other machines.  </p>