AJAX Forums

auto-refresh?

This is a discussion on auto-refresh? within the AJAX Questions forums, part of the Beginners AJAX category; I have this simple code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&...

Old 08-14-2008, 11:18 AM   #1 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 3
Rep Power: 0 h4x0rmx is on a distinguished road
Arrow auto-refresh?

I have this simple code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
<!--
	var xmlhttp = false;

	try{
	    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e){
	    try{
	        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (E){
		    xmlhttp = false;
		}
	}

	if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
	    xmlhttp = new XMLHttpRequest();
	}

	function makerequest(serverPage, objID){
	    var obj = document.getElementById(objID);
	    xmlhttp.open("GET", serverPage);
	    xmlhttp.onreadystatechange = function(){
	        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
	            obj.innerHTML = xmlhttp.responseText;
	            setTimeout(makerequest(serverPage,objID),1000);
			}
		}
		xmlhttp.send(null);
	}

window.onload=function(){
	setTimeout(makerequest('inner.php','first'),1000);
}

//-->
</script>
</head>
<body >
	<div align="center">
	    <h1>Testing</h1>
	</div>
	<div id="first">loading...</div>
	<div id="second">...and loading...</div>
</body>
</html>
I'm just testing an "auto-refresh" function that I need to use. The page that I call (inner.php) just displays the current time (for now). It seems to be working alright in Firefox, but not in IE. Also, in Firefox I get an error: useless setTimeout call(missing quotes around argument?) and I don't know how to fix it. Any ideas?
Also, I tried calling the same setTimeout function sending it the id for the second div, but it doesn't do anything. How could I have different divs auto-refreshing at different rates?

Any help will be really appreciated!
h4x0rmx is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Page refresh sandy1028 AJAX Help 0 10-06-2008 06:34 AM
AJAX Jobs : Website section I don't want to refresh by Timoitserv admin AJAX Freelance Jobs 0 09-18-2008 05:07 PM
AJAX Jobs : Automatic refresh in a website by Lucianodec admin AJAX Freelance Jobs 0 07-09-2008 05:14 PM
auto-popup info button MMC25 AJAX Help 0 08-14-2007 05:42 AM
CSS auto size div? zubairv85 XHTML and CSS 0 06-19-2007 08:48 PM


All times are GMT -4. The time now is 09:02 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com