Hi All,

the following code is used to get an update from a database. My question is how can I use this more than once on a page to call two different queries (from different php files)?

<script type="text/javascript">
function showHint(str)
  if (window.XMLHttpRequest)
    xmlhttp = new XMLHttpRequest();
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

  xmlhttp.onreadystatechange = function()
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
      document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
  xmlhttp.open("GET", "console4.php" + str, true);
<script type="text/javascript">showHint(this.value)</script>

<p><span id="txtHint"></span></p> 

      <script type="text/javascript">
      function keepCalling() {
      window.setTimeout("keepCalling()", 2000) ;// call the showHint every (2)000 second

I would extend the function showHint to accept two more parameters: the first being the php file to call, and the second the elementId to update. That way you can keep using the same function.