PDA

View Full Version : Ajax autorefresh not working with Internet Explorer 6


Lleoun
06-12-2009, 02:01 PM
Hi all,

The code below refreshes mypage.php every 3 seconds without blinking or anything you can notice when seeing the page.
This is working for all browsers except for Internet Explorer 6. When using IE6 the text in mypage.php does not move but the images blink with every refresh.
Here's the page:
http://vivocom.es/test/prensa/index_autorefresh.html

Any ajax genius can modify the script so it can work also for Internet Explorer 6? or even make a new script for Internet Explorer 6 ( I'll detect the browser and I'll show one or the other)..

Thanks a ton in advance!



<script type="text/javascript">
function getHTTPObject() {

var request = false;
try {
request = new ActiveXObject('Msxml2.XMLHTTP');
}
catch (err2) {
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
catch (err3) {
try {
request = new XMLHttpRequest();
}
catch (err1)
{
request = false;
}
}
}
return request;

}

var ajaxRequest = getHTTPObject(); // creating HTTP Object

setInterval(getPage, 3000); // 3 secs
function getPage() {


// ajaxRequest.open("GET", "mypage.php", true);
ajaxRequest.open("GET", "mypage.php"+"?dummy="+new Date().getTime(), true)
ajaxRequest.onreadystatechange = showPage;
ajaxRequest.send(null);


}

function showPage()
{
if(ajaxRequest.readyState == 4){

var ajaxDisplay = document.getElementById('show');
ajaxDisplay.innerHTML = ajaxRequest.responseText;


}
}
window.onload=function(){
getPage();
}
</script>

</head>
<body>

<div id="show" ></div>


mypage.php


<?php
echo"Here a text that don't blink but the image below does it (when using IE6) every 3 seconds
<br><br><img src='http://dertompson.com/wp-content/uploads/2008/03/memory-verlauf-ie-reload.png'>";
?>

A1ien51
06-13-2009, 02:04 PM
I do not understand your problem "the text will not move". Is it not getting the new data? What does that mean?

Eric