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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2006
    Location
    Bristol, UK
    Posts
    85
    Thanks
    6
    Thanked 6 Times in 6 Posts

    Issue with Ajax call making IE hang

    Hi,
    I've just implemented my first bit of Ajax, calling an XML file to show live scores on a website. Everything seems to be fine on FF3 and Safari, but when the site is opened in IE7, a script error is thrown and it's impossible to navigate to any other page.

    The Ajax is as follows:

    Code:
    <script type="text/javascript">
    function Ajax(){
    var xmlHttp;
    	try{	
    		xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
    	}
    	catch (e){
    		try{
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
    		}
    		catch (e){
    		    try{
    				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e){
    				alert("Sorry, your browser doesn't allow AJAX.");
    				return false;
    			}
    		}
    	}
    
    xmlHttp.onreadystatechange=function(){
    	if(xmlHttp.readyState==4){
    		document.getElementById('midFooter').innerHTML=xmlHttp.responseText;
    		setTimeout(Ajax(),60000);
    	}
    }
    xmlHttp.open("GET","/includes/livescores.asp",true);
    xmlHttp.send(null);
    }
    
    window.onload=function(){
    	setTimeout(Ajax(),60000); //***** Error line as described below *****
    }
    </script>
    The script error that Internet Explorer throws is:
    Line: 42
    Char: 2
    Error: Invalid Argument

    Line 42 is the line above with asterixs in it...

    I'm hoping that it's something simple that I've missed...

    Any help would be greatly appreciated.

    Thanks.
    Last edited by dudeshouse; 02-23-2009 at 04:08 PM. Reason: More information
    Never argue with an idiot... they'll bring you down to their level and beat you with experience...

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Try to add highlighted:
    Code:
    setTimeout('Ajax()',60000);
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    dudeshouse (02-23-2009)

  • #3
    New Coder
    Join Date
    Nov 2006
    Location
    Bristol, UK
    Posts
    85
    Thanks
    6
    Thanked 6 Times in 6 Posts
    Wow, the simplest things eh?

    Worked perfectly, thank you very much.
    Never argue with an idiot... they'll bring you down to their level and beat you with experience...


  •  

    Posting Permissions

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