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"> <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; ...

Go Back   AJAX Forums > Beginners AJAX > AJAX Questions

AJAX Made Easy


AJAX Questions Ask Ajax Questions Here!

Reply

 

LinkBack Thread Tools Display Modes
Old 08-14-2008, 10: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
Sponsored Links
Reply

Bookmarks


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

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Page refresh sandy1028 AJAX Help 0 10-06-2008 05:34 AM
auto-popup info button MMC25 AJAX Help 0 08-14-2007 04:42 AM
CSS auto size div? zubairv85 XHTML and CSS 0 06-19-2007 07:48 PM


All times are GMT -4. The time now is 01:24 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0
Copyright ©2006 - 2009, AJAXwith.com