Hi All, I'm an AJAX beginner, I've copied a (basic) code from the book I'm reading and it behaves stubbornly wrong when I run it...
here is the code that I think gives me the problem:
Code:
var http = getXMLHttpRequest(); // this gets an instance of XMLHttpRequest object. 

function getServerTime(){

 var url = "time.php"; 
 var rdm = parseInt( Math.random()*999999 ); 
 var myURL=url+"?myRdm="+rdm; 
 http.open( "GET", myURL, true );
 http.onreadystatechange=useHttpResponse(); 
 http.send( null );  
}

function useHttpResponse(){

alert ( "request status: "+ http.statusText ); 

if( http.readyState == 4 ){ 
alert(1); 
 if( http.status== 200 ){

alert(2); 	
	var timeNow = http.responsexml.getElementsByTagName( 'timenow' )[0]; 
	var timeVal = timeNow.childNodes[ 0 ].nodeValue;
alert( timeVal );  
	document.getElementById( 'showtime' ).innerHTML = timeVal; 
 }else{
	alert(3); 	
	document.getElementById( 'showtime' ).innerHTML= http.statusText; 
 }
}else{
alert(4); 
 document.getElementById( 'showtime' ).innerHTML = "...waiting";   
}
}
In the function useHttpResponse(),

I expect some of the alerts to work, but none do. I can print out the http.readyState value ( which is always 1 ) but not http.status or http.statusText

Please please advice....will be much appreciated.

this is the php file: time.php
PHP Code:
<?php 
header 
'Content-Tye: text/xml' ); 
 echo 
"<?xml version=\"1.0\" ?> <clock1> <timenow>"
.date('H:i:s')."</timenow></clock1>"
?>