Web Design Forum: setTImeout function not working in firefox - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

setTImeout function not working in firefox

#1 User is offline   webbhost 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 192
  • Joined: 12-May 08
  • Reputation: 0
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 14 January 2012 - 09:00 PM

Hi All,

Okay this ones bugging the hell out of me... the following code WORKS in I.E. and it even works in my friends Firefox browser... but on my own firefox browser, it runs init once and then refuses to repeat?

I have tried debugging it and have got it down to the point where its adding "xmlhttp.send();" that stops it.

If I remove that line then everything works fine??


Can anyone please give advice?

	

	


	function init(){
				alert ("init");
		var xmlhttp;
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
			xmlhttp.onreadystatechange=function()
			  {
			  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			    {
				    var response = xmlhttp.responseText;
					if (response == "1"){
						loadInterface();
					}else{
					}	
			    }
			  }
		xmlhttp.open("GET","LiveAssistanceHandle.php?PickedUp=check&refresh=" + (new Date().getTime()),true);
		xmlhttp.send();
		setTimeout("init()",2000);

	}


	window.onload = init;

0

#2 User is offline   webbhost 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 192
  • Joined: 12-May 08
  • Reputation: 0
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 14 January 2012 - 09:05 PM

checked it on brothers comp too which is firefox, and works fine for him too? Could this be something to do with browser version?
0

#3 User is online   Barth 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 30
  • Joined: 26-July 10
  • Reputation: 7
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 14 January 2012 - 10:12 PM

Something simple like this may solve your problem


setTimeout(function(){init();}, 2000);


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users