我正在使用 jquery ajax 在模糊上使用用户名
respose 可以进入 firebug
我的问题是加载图像一直在旋转。
Firebug 控制台中的 ReferenceError:finishAjax 未定义
setTimeout("finishAjax('Info', '"+escape(response)+"')", 450); 这是它
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<link href="css.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function check_username() {
$.post("check_username_availablity.php", {
username: $('#name').val(),
}, function(response){
//$('#Info').fadeOut();
//$('#Loading').hide();
setTimeout("finishAjax('Info', '"+escape(response)+"')", 450);
});
function finishAjax(id, response) {
$('#'+id).html(unescape(response));
//$('#'+id).fadeIn(1000);
}
}
</script>
</head>
<?php
include('dbcon.php');?>
<body>
<form action="#" name="customForm" id="customForm" method="post" enctype="multipart/form-data">
<div class="both">
<h4> Try "Zeeshan" , "John" , "Katty", "Jimmy" </h4><br clear="all" /><br clear="all" />
<br clear="all" />
<div>
<label>User Name</label>
<input id="name" name="username" type="text" value="" onblur="check_username()"/>
<div id="Info"></div>
<span id="Loading"><img src="loader.gif" alt="" /></span>
</div>
</div>
</form>
</body>
</html>
<?php
include('dbcon.php');
if($_REQUEST)
{
$username = $_REQUEST['username'];
$query = "select * from register where username = '".strtolower($username)."'";
$results = mysql_query( $query) or die('ok');
if(mysql_num_rows(@$results) > 0) // not available
{
echo '<div id="Error">Already Taken</div>';
}
else
{
echo '<div id="Success">Available</div>';
}
}?>
谢谢..