First AJAX Attempt

I have started off with a basic html form and javascript function to begin with. Following this I will implement PHP scripting to communicate with mySQL etc.


<title>test ajax</title>
<form name="user">
<input id="name" type="text" name="name" onkeyup="keyup(event.keyCode);"/>
<input type="button" value="Go" onclick="submit_msg();" />
<script type="text/javascript">
var foc = document.getElementById("name");
function submit_msg()
name = document.getElementById("name").value;
if(name.length > 0)
document.write("hello "+name);
return true;
else {
document.write("hmm, no name");
return false;
/* Check if Enter is pressed */
function keyup(arg1) {
if (arg1 == 13) submit_msg();

I have found when using document.write(); it requires document.close() to end the stream.
With the above code, it seems to cache the name somehow.