Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax autorefresh not working with Internet Explorer 6

    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!

    Code:
    <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

    Code:
    <?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'>";
    ?>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    I do not understand your problem "the text will not move". Is it not getting the new data? What does that mean?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •