I’m having problem getting HTTPRequest to work the way I want. Greatly simplified code below (IE only shown).
I have a page that tracks a number of updates, occuring elsewhere, to a database. Click on ‘Test It’ and the latest number is displayed without having to refresh the page. (bit like a stock ticker)
In this example, the ‘alert’ box shows the number (returned by the test.cgi script). Update the number in test.cgi (in another window), click ‘Test It’ and the new number should be displayed.
On my local machine it all works as expected but when working on the server, the original number, not the updated number, is displayed. (test.cgi simply returns a ‘text/plain’ number).
Now here’s the really strange part.
If I run the test.cgi in a different window (on the same machine) it returns the updated number. Now if I go back and click ‘Text It’ the updated number is displayed. (test.cgi simply returns the latest number from the database)
I hope I explained that so you can understand the problem.
[code][size=1]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html><head><title>untitled</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<meta http-equiv=”Content-Script-Type” content=”text/javascript”>
<meta http-equiv=”Content-Style-Type” content=”text/css”>
<script type=”text/javascript”>
<!–
var xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);
function http_test() {
xmlhttp.open(“GET”,”/cgi-bin/test.cgi?data”,true);
xmlhttp.onreadystatechange = get_data;
xmlhttp.send(null);
}
function get_data() {
if (xmlhttp.readyState == 4) {
alert(xmlhttp.responseText);
}
}
//–>
</script>
</head>
<body>
<p><a href=”” onclick=”http_test(); return false;”>Test It</a></p>
</body>
</html>
[/size]