SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Refresh data without refreshing page

    Hi,

    I have the following code for grabbing changing data and displaying it on my site without refreshing my page. I have two different zones on the page that need to refresh, and am using the following code...

    Code:
    <script type="text/javascript">
    
    var req1;
    var req2;
    
    function Init(){
        try{
            req=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
            try{
                req=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(oc){
                req=null;
            }
        }
        if(!req&&typeof XMLHttpRequest!="undefined"){
            req = new XMLHttpRequest();
    	}
    	return req;
    }
    function get_table(){
      	req1=Init();
      	if(req1!=null){
    
    	    req1.onreadystatechange = getResult;
    	    req1.open("get", "table8.php", true);
    	    try {
    	       req1.send(null);
    	    } catch (ex) { alert("Error!");}
    
    	}
            setTimeout("get_table()",1000*10);
    }
    
    function get_results(){
      	req2=Init();
      	if(req2!=null){
    
    	    req2.onreadystatechange = getResult2;
    	    req2.open("get", "results8.php", true);
    	    try {
    	       req2.send(null);
    	    } catch (ex) { alert("Error!");}
    
    	}
    	setTimeout("get_results()",1000*10);
    }
    
    function getResult(){
      if (req1.readyState == 4){
        if (req1.status == 200){
         document.getElementById("whoever").innerHTML=req1.responseText;
    
        }
        else {
            alert("Internal Server Error!");
        }
      }
    }
    
    function getResult2(){
      if (req2.readyState == 4){
        if (req2.status == 200){
         document.getElementById("whoever2").innerHTML=req2.responseText;
    
        }
        else {
            alert("Internal Server Error!");
        }
      }
    }
    
    </script>
    This works perfectly in all browsers except IE. In IE only the data from results8.php - function getResult2() - refreshes, while the data from table8.php - function getResult() does not refresh.

    However, if I visit table8.php in another window and refresh that page manually, the data will refresh on my main page within a few seconds.

    Does anyone have any idea why this is not working and what I can do?

    Thanks a lot

  2. #2
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nothing?

    If not, anyone know where else I could look?


Bookmarks

Posting Permissions

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