AJAX Suggestions... Some Event dont work..

Discussion in 'PHP' started by bartolay13, Dec 2, 2007.

  1. #1
    hello again,

    got a problem with my ajax scripts... some of them doesnt work on IE browsers..
    ie,
    
    var xmlHttp // variable for the request
    
    var c=0
    var t
    function timedCount()
    {
    	document.getElementById('txt').value=c
    	c=c+1
    	t=setTimeout("timedCount()",1000)
    }
    
    function ajaxFunction()
    {
    	xmlHttp = GetXmlHttpObject() // set the xmlHttp first
    	
    	if(xmlHttp == null)
    	{
    		alert("Your Browser Doesnt Support AJAX.!");	
    	}
    	else if(xmlHttp != null)
    	{		
    		var c=0
    		var t
    		//alert("Browser Supported "+url);
    		//document.getElementById('txt').value=c
    		var url = "status.php"
    		xmlHttp.onreadystatechange=stateChanged // pre-defined function 
    		xmlHttp.open("GET",url,true)
    		xmlHttp.send(null)
    
    		t=setTimeout("ajaxFunction()",1000)
    	}
    }
    	
    		function stateChanged() 
    		{ 
    			if (xmlHttp.readyState==4)
    			{ 
    				document.getElementById("ajax").innerHTML=xmlHttp.responseText
    			} 
    		}
    
    	function GetXmlHttpObject()
    	{ 
    		var objXMLHttp=null
    		if (window.XMLHttpRequest)
    		{
    			objXMLHttp=new XMLHttpRequest()
    		}
    		else if (window.ActiveXObject)
    		{
    			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    		}
    		return objXMLHttp
    	}
    	
    
    PHP:
    simple ajax, all parts work on Internet Explorer and FF.. but setTimeout doesnt work in IE.. This line refreshes the script every second.. works fine in FF.

    Thanks in Advance.
     
    bartolay13, Dec 2, 2007 IP