troubleshooting Question

AJAX response returns the same value only requesting current date time

Avatar of n2alexan
n2alexan asked on
JavaScriptASP.NETVisual Basic.NET
3 Comments1 Solution607 ViewsLast Modified:
Hi,

I have a very simple webapp that has this index.htm page:

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

    <script type="text/javascript">
            
            function GetXmlHttp() {      
      var xmlhttp = false;
      if (window.XMLHttpRequest)
      {
            xmlhttp = new XMLHttpRequest();
  }
      else if (window.ActiveXObject)// code for IE
      {
            try
            {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {
                  try
                  {
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                        xmlhttp=false;
                  }
            }
      }
      return xmlhttp;
}

            function ajaxFunction(url)
  {  
    var xmlHttp = GetXmlHttp();
 
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("ajaxin").value = document.getElementById("ajaxin").value + '|' + xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
   }
   

    </script>
   
</head>
<body>
    <input id="Button1" onclick="ajaxFunction('ajax/tracker.aspx');" type="button" value="button" />
    <input id="ajaxin" style="width: 100%; height: 544px" type="text" />
</body>
</html>

======
and I use aspx page to write back the date and time

<% Response.Write(DateTime.Now) %>

but every time I press the button I get the same datetime and it's value is not changed, even after 1 minute.
The values of seconds is not updated.

Could someone explain what is happenning here.

Thank you very much,
N.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros