Image

Hi there, I have a quick question.

This script is fairly simple. It works great in firefox, doesn't seem to work in IE. My document.getElementById('theTime').value gets set in firefox, but not in IE. Anyone have any ideas?



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>XmlHttpRequest</title>

<script language="javascript" type="text/javascript">
  var url = "echotime.php?param=";
  var http = getHTTPObject();
  
  function startAjax()
  {
    getTime();
    setInterval('getTime();', 5000);
  }
  
  function handleHttpResponse()
  {
    if (http.readyState == 4)
    {
   if (http.status == 200)
   {
         document.getElementById('theTime').value = http.responseText;
   }
   else
   {
   alert("There was a problem retrieving the XML data:\n" + http.statusText);
   }  
    }
  }
  
  function getTime()
  {
    http.onreadystatechange = handleHttpResponse;
    http.open("GET", url, true);
    http.send(null);
  }
  
  function getHTTPObject()
  {
   if (window.XMLHttpRequest)
   {
      try
      {
        xmlhttp = new XMLHttpRequest();
      }
      catch (e)
      {
        xmlhttp = false;
      }
   }
   else if (window.ActiveXObject)
   {
      try
      {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
        window.alert("ms.xmlhttp");
        try
        {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
          xmlhttp = false;
        }
      }
   }
   return xmlhttp;
  }
</script>

</head>
<body onload="startAjax();">

<form action="post" ID="theForm">
  <label for="time">time</label>
  <input type="text" name="test" id="theTime" width="200px" size="200px" value="crap"/>
</form>
</body>
</html>