Help! Subsequent Get Requests using xmlhttp return identical results

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tlang

    Help! Subsequent Get Requests using xmlhttp return identical results

    Has anybody experienced the following? The below Get request is called
    when a button on the page is clicked:

    function GetTranscript() {
    var oSend = new ActiveXObject(" Msxml2.XMLHTTP. 3.0");
    oSend.Open("GET ", "transcript.asp x", true);
    oSend.onreadyst atechange = function() {
    if (oSend.readySta te == 4) {
    alert(oSend.res ponseText);
    }
    }
    oSend.send(null );
    oSend = null;
    return false;
    }

    The page transcript.aspx returns the current date, i.e.
    private void Page_Load(objec t sender, System.EventArg s e)
    {
    // Put user code to initialize the page here
    Response.Write( System.DateTime .Now.ToLongTime String());
    Response.End();
    }

    The first call through xmlhttp works great. Subsequent calls return
    the same exact time.

    HELP! Dont know what else to do.

    dead in the water,
    Tom

  • Randy Webb

    #2
    Re: Help! Subsequent Get Requests using xmlhttp return identicalresult s

    tlang wrote:[color=blue]
    > Has anybody experienced the following? The below Get request is called
    > when a button on the page is clicked:
    >
    > function GetTranscript() {
    > var oSend = new ActiveXObject(" Msxml2.XMLHTTP. 3.0");[/color]

    It may be that it's getting the page from a cache somewhere, but never
    experienced this problem. What you can try doing is making the file name
    unique so that it forces it from the server:

    myFile = "transcript.asp x?" + new Date().getTime( );
    [color=blue]
    > oSend.Open("GET ", "transcript.asp x", true);[/color]

    oSend.Open("GET ",myFile,tr ue);

    It may work, it may not, but worth trying.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • tlang

      #3
      Re: Help! Subsequent Get Requests using xmlhttp return identical results


      Thanks Randy. This worked:
      <script language="javas cript">
      function GetTranscript() {
      var oSend = new ActiveXObject(" Msxml2.XMLHTTP. 3.0");
      myFile = "transcript.asp x?time=" + new Date().getTime( );
      oSend.Open("GET ", myFile, true);
      oSend.onreadyst atechange = function() {
      if (oSend.readySta te == 4) {
      alert(oSend.res ponseText);
      oSend = null;
      }
      }
      oSend.send(null );
      return false;
      }
      </script>

      Not sure why the output of the aspx file was cached. I thought the
      point of aspx files is that their contents is dynamic. I would think
      making it static would be an explicit property setting. I'll try to
      find out more info on that.

      Tom

      Comment

      • kdarling@basit.com

        #4
        Re: Help! Subsequent Get Requests using xmlhttp return identical results

        >Not sure why the output of the aspx file was cached. I thought[color=blue]
        >the point of aspx files is that their contents is dynamic.[/color]

        What you saw is normal.

        Page contents can be dynamic, but unless you specify a different URL
        (or use a POST instead of a GET), the browser will use the page with
        the same URL from cache. (Assuming you haven't used an expiration date
        or other methods to prevent that.)

        We have an internal site that makes extensive use of cached files to
        speed up usage over dialup. To force a download, we use the method as
        was suggested... adding the date to create a new version parameter.

        Kev

        Comment

        • Diego Vilar

          #5
          Re: Help! Subsequent Get Requests using xmlhttp return identical results

          Randy is right... transcript.aspx is being cached.... I've had the same
          problem, and it can be quickly solved just by sending no-cache request
          headers... For IE, the following alone will do it:

          oSend.setReques tHeader("If-Modified-Since","Wed, 15 Nov 1995 04:58:08
          GMT");

          Don't know for other browsers, but try these:

          oSend.setReques tHeader("Expire s", "Wed, 15 Nov 1995 04:58:08 GMT");
          oSend.setReques tHeader("Last-Modified", "Wed, 15 Nov 1995 04:58:08
          GMT");
          oSend.setReques tHeader("Cache-Control", "no-cache, must-revalidate");
          oSend.setReques tHeader("Pragma ", "no-cache");

          Let us know if it worked..

          [ ]'s
          Diego

          Comment

          Working...