All pastes #490797 Raw Edit

Something

public text v1 · immutable
·published 2007-05-16 07:47 UTC
rendered paste body
<html>
<head>
<title>Ajaxerific</title>

<script type="text/javascript" language="javascript">
function ajaxFunction(){
	var xmlHttp;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e){
		// Internet explorer
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				alert("Your web browser does not support AJAX");
				return false;
			}
		}
	}
}

xmlHttp.onreadystatechange = function(){
	// We are going to write some code here
	if(xmlHttp.readyState == 4){
		document.myForm.time.value=xmlHttp.responseText;
	}
}

xmlHttp.open("GET","time.php",true);
xmlHttp.send(null);
</script>

</head>
<body>
<form name="myForm">
	Name: <input type="text" name="username" onkeyup="ajaxFunction();" /><br />
	Time: <input type="text" name="time" />
</form>
</body>
</html>