CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    1

    Ajax autoreferesh works fine with FireFox but doesn't work with IE

    hi I am using the following code for refreshing a div through ajax, it works fine FireFox but doesn't work at all with IE. Infact the function is called after every 10 seconds but it doesn't send the call to server while using IE. Can anyone will help me out please...

    Code:
    function startTimer(sessionId, jsPageRefreshInterval){
    param = "refreshInterval";
    
    // alert(param + " = " + refreshInterval + " = " + sessionId + " = " + jsPageRefreshInterval);
    try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }catch (e){
    // Internet Explorer
    try{
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch (e){
    try{
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }catch (e){
    alert("Your browser does not support AJAX!");
    return false;
    }
    }
    }
    
    xmlHttp.open("GET","JobControllerUtilServlet?" + "sessionId=" + sessionId + "&paramChanged=true&param=" + param + "&value=" + refreshInterval, true);
    xmlHttp.onreadystatechange = function()
    {
    if(xmlHttp.readyState == 4 || xmlHttp.readyState=='complete')
    {
    document.getElementById('theTable').innerHTML = xmlHttp.responseText;
    dkc=setTimeout("startTimer('" + sessionId + "', '" + jsPageRefreshInterval + "');", 10000);
    return true;
    }
    }
    xmlHttp.send(null);
    }
    Last edited by PeejAvery; November 10th, 2008 at 02:44 PM.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Ajax autoreferesh works fine with FireFox but doesn't work with IE

    Why do you have || xmlHttp.readyState=='complete' to check for the state of the request? Take that part out since the readyState will always return a number.

    Also, why are you returning true for the function before you can even sent the request? I would suggest removing the return as well.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured