R
Robert S
I am trying to get the output of a php script to be displayed on a page
using the following (I have drastically simplified the PHP script and
have used MSXML2.XMLHTTP.4.0):
time.html:
<html>
<head>
<script type="text/javascript" language="javascript">
var xmlhttp;
function loadXMLDoc() {
xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP.4.0");
}
if (xmlhttp!=null) {
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200) {
document.getElementById("refresher_div").innerHTML =
xmlhttp.responseText;
setTimeout("loadXMLDoc()", 1000);
}
};
xmlhttp.open("GET","time.php",true);
xmlhttp.send(null);
} else {
alert("Your browser does not support XMLHTTP.");
}
}
</script>
</head>
<body>
<center>
<div name="refresher_div" id="refresher_div">
Time will display here!!
</div>
</center>
</body>
</html>
<script language="javascript">
loadXMLDoc();
</script>
-----------------------------------8><-------------------------------------------
time.php:
<?php print date("r"); ?>
-----------------------------------8><-------------------------------------------
It all works fine in Firefox, but in IE6 and 5.0 the time does not
refresh on the page. Looking at the web server log, time.php does not
seem to load every second when it is running in IE6, and, using the
Script Debugger, the value of xmlhttp.responseText does not get
updated.
What am I doing wrong?
I've tried different versions of MS XMLHTTP, and have tried synchronous
GET statements, but no joy. I've tried debugging it with alert(
xmlhttp.responseText ), and it doesn't get updated. I've also tried
rearranging things, but the same fundamental problem remains.
using the following (I have drastically simplified the PHP script and
have used MSXML2.XMLHTTP.4.0):
time.html:
<html>
<head>
<script type="text/javascript" language="javascript">
var xmlhttp;
function loadXMLDoc() {
xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP.4.0");
}
if (xmlhttp!=null) {
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200) {
document.getElementById("refresher_div").innerHTML =
xmlhttp.responseText;
setTimeout("loadXMLDoc()", 1000);
}
};
xmlhttp.open("GET","time.php",true);
xmlhttp.send(null);
} else {
alert("Your browser does not support XMLHTTP.");
}
}
</script>
</head>
<body>
<center>
<div name="refresher_div" id="refresher_div">
Time will display here!!
</div>
</center>
</body>
</html>
<script language="javascript">
loadXMLDoc();
</script>
-----------------------------------8><-------------------------------------------
time.php:
<?php print date("r"); ?>
-----------------------------------8><-------------------------------------------
It all works fine in Firefox, but in IE6 and 5.0 the time does not
refresh on the page. Looking at the web server log, time.php does not
seem to load every second when it is running in IE6, and, using the
Script Debugger, the value of xmlhttp.responseText does not get
updated.
What am I doing wrong?
I've tried different versions of MS XMLHTTP, and have tried synchronous
GET statements, but no joy. I've tried debugging it with alert(
xmlhttp.responseText ), and it doesn't get updated. I've also tried
rearranging things, but the same fundamental problem remains.