title: How to call JS function continuously after every 5 seconds
body: <p>I have following codes: </p>
  
  <p>JSP code is as follows:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="js/nextprevpage.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onload="javascript:first();"&gt;
  
  &lt;div id="getData"&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code present in nextprevpage.js is as follows:</p>
  
  <pre><code>function first()
  {
  
  var xmlhttp;
  if (window.XMLHttpRequest) 
  {       // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
  } 
  else 
  {   // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange = function() 
  {
      if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) 
      {
          document.getElementById("getData").innerHTML= xmlhttp.responseText;
      }
  }
    // here you make a request to your script to check your database...
  xmlhttp.open("POST", "updatesession.jsp?", true);
  xmlhttp.send();
  }
  </code></pre>
  
  <p>Now I have another jsp page as updatesession.jsp.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  
  &lt;body "&gt;
   Hello......
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I called above js function using onload() event. I need to call this js function continuously. Is there any way to call this function every after 5 seconds.</p>