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.

Code:

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

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.