By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

Help! Subsequent Get Requests using xmlhttp return identical results

P: n/a
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.aspx", true);
oSend.onreadystatechange = function() {
if (oSend.readyState == 4) {
alert(oSend.responseText);
}
}
oSend.send(null);
oSend = null;
return false;
}

The page transcript.aspx returns the current date, i.e.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Response.Write(System.DateTime.Now.ToLongTimeStrin g());
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

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
tlang wrote:
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");
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.aspx?" + new Date().getTime();
oSend.Open("GET", "transcript.aspx", true);


oSend.Open("GET",myFile,true);

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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

P: n/a

Thanks Randy. This worked:
<script language="javascript">
function GetTranscript(){
var oSend = new ActiveXObject("Msxml2.XMLHTTP.3.0");
myFile = "transcript.aspx?time=" + new Date().getTime();
oSend.Open("GET", myFile, true);
oSend.onreadystatechange = function() {
if (oSend.readyState == 4) {
alert(oSend.responseText);
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

Jul 23 '05 #3

P: n/a
>Not sure why the output of the aspx file was cached. I thought
the point of aspx files is that their contents is dynamic.


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

Jul 23 '05 #4

P: n/a
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.setRequestHeader("If-Modified-Since","Wed, 15 Nov 1995 04:58:08
GMT");

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

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

Let us know if it worked..

[ ]'s
Diego

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.