Wrox Programmer Forums
|
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2003, 10:30 PM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSXML2.XMLHTTP Caching?

I've been trying to use MSXML2.XMLHTTP to refresh content on a page without reloading the entire page. Any idea why the request I make is permanently cached? The program works and gets the new data from an HTML file, but it always stays the same even after I run a refresh. The only way to clear it is to shut down the Web browser and load it again. It looks like MSXML2.XMLHTTP is caching the request permanently in teh browser session. This will not work for me because the content in the HTML page changes.

Please help. The illustration below SHOULD refresh the DIV every 3 seconds. The LoadNew() function does definitely run every 3 seconds (I tested it by putting an alert in there). The problem is that xmlhttp.open("get",filename,false) is cached and always returns the exact same data. I can even delete the myfile.cfm file and it will still return the cached content instead of a 404. Any way to prevent this caching effect?????

Illustration:

<html>
<head>
<title>DIV should change without reloading page.</title>
<script type="text/javascript">
<!--
var xmlhttp = false

// Creating XMLHTTP Start
 try {
 xmlhttp=new ActiveXObject("MSXML2.XMLHTTP")

} catch (e) {
 }

if (!xmlhttp) {
try {
 xmlhttp = new XMLHttpRequest();
} catch (e) {
}
}
// Creating XMLHTTP End


function LoadNew() {

if (!xmlhttp) {alert("Your browser doesn't support XMLHTTP.\nYou need IE5+ or NN 6.1+");return}
var filename = "/myfile.asp";
xmlhttp.open("GET",filename,false);
xmlhttp.onreadystatechange=function() {
 if (xmlhttp.readyState==4) {
         var html = xmlhttp.ResponseText;
         if (xmlhttp.status==404) {alert("The page doesn't exist on the server !!!");return}
   document.getElementById("dynamic").innerHTML = html;
 }
}
// xmlhttp.open("DELETE",filename,true);
xmlhttp.send();
// xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
// xmlhttp.close;
setTimeout("LoadNew()",3000);
}


// -->
</script>
</head>
<body>
<p>This channel should reload every 3 seconds. <a href="javascript:LoadNew();">Force reload now</a></p>

<div id="dynamic">
  Dynamic part
</div>

<script type="text/javascript">
    setTimeout("LoadNew()",3000);
</script>

</body>
</html>
 
Old September 17th, 2003, 02:24 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hit this problem yesterday the fix is to add NOW to your get line like this:

xmlhttp.open("GET",filename & Now,false);

That should force it to fetch a new page each time.

Aarpm


 
Old September 19th, 2006, 01:02 PM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This didn't work for me.
Error: 'Now' is undefined
Perhaps something was left out?

I changed my code to the following to stop caching:
req.open("POST",url +"&rnd="+(new Date()).getTime(), true);






Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript, Msxml2.XMLHTTP - Spanish Characters Pr itHighway Classic ASP Basics 1 November 14th, 2008 09:20 PM
Object Required Error When Using MSXML2?!?! kevorkian XML 16 January 15th, 2007 04:34 PM
MSXML2 Type mismatch desperado1306 Excel VBA 0 June 2nd, 2006 12:18 PM
MSXML2.ServerXMLHTTP help appreciated!! Steven1984 Classic ASP Professional 0 June 4th, 2005 12:49 PM
MSXML2.XMLHTTP Caching? spraguey Javascript 2 December 6th, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.