delay on ajax post

delay on ajax post

Hi,

I'm desperately trying to finish a form validation script. I built a script to check whether or not a username is picked (the rest of the functions have been removed). This part works perfectly except only one out of every 30 or so submits actually throws the alert. I use Bluehost and I'm not sure if the server is just really slow to respond or my code is written poorly. I'd really love some feedback. Thanks.

HTML + JQUERY
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="styles/base.css" rel="stylesheet" type="text/css" />
<script src="jquery/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
/*process form data*/
function process(){
var username = $("#username").val();
  $.post("php/namecheck.php",{username: username}, function(data){
  alert(data);/*alert back data to check success for now*/
  });
}
</script>
</head>

<body>
<div id="signUp">
<div class="top"></div>
<div id="windowBodySmall">
<h2 class="header">Create An Account</h2>
<div class="warning"></div>
<div class="spacer"></div>
<form method="post">
<h2>Email</h2>
<input type="text" name="email" id="email"/>
<h2>Desired Username</h2>
(6-15 Non-Special Characters)
<input type="text" name="username" id="username" />
<h2>Password</h2>
(6-15 Non-Special Characters)
<input type="password" name="pass" id="pass" />
<h2>Password Again</h2>
<input type="password" name="repass" id="repass"/>
<input type="submit" name="submit" onmousedown="process();" value="submit" />
</form>
</div>
<div class="bottom"></div>
</div>
</body>
</html>


PHP

<?php
$username = $_POST['username'];
include('dbnode.php');
if($select){
$query = 'SELECT username FROM mf_user WHERE username = "'.$username.'"';
$result = mysql_query($query);
$row = mysql_num_rows($result);
echo($row);
}
?>