我正在制作一个注册表,它将检查输入的手机号码是否正在使用,就像在twitter的用户名检查中一样。我的代码看起来很完美,但我一直在'检查号码可用性',就像ajax没有发送我的请求。帮助请:-) 这里是有关Ajax代码位Ajax Live数据库检查
<script type="text/javascript">
$(document).ready(function()//When the dom is ready
{
$("#cellphone_number").change(function()
{ //if theres a change in the username textbox
var phonenumber = $("#cellphone_number").val();//Get the value in the username textbox
if(phonenumber.length == 13)//if the lenght equal to 13 characters
{
$("#availability_status").html('<align="absmiddle"><font color="#00FF33">Checking Number availability...</font>');
//Add a loading image in the span id="availability_status"
$.ajax({ //Make the Ajax Request
type: "POST",
url: "../Functions/ajax_check_number.php", //file name
data: ("number="+phonenumber), //data
success: function(server_response)
{
$("#availability_status").ajaxComplete(function(event, request){
if(server_response == '0')//if ajax_check_username.php return value "0"
{
$("#availability_status").html('<align="absmiddle"> <font color="#00FF33">Number is Available </font> ');
//add this image to the span with id "availability_status"
}
else if(server_response == '1')//if it returns "1"
{
$("#availability_status").html('<align="absmiddle"> <font color="#FF0000">Number already in use</font>');
}
});
}
});
}
else
{
$("#availability_status").html('<font color="#FF0000">Number too short</font>');
//if in case the username is less than or equal 3 characters only
}
return false;
});
});
</script>
请格式化代码正确 – cambraca 2010-11-09 17:37:35
的代码是所有靠不住的......我会修复它,但我没有权限... – 2010-11-09 17:37:48
您是否尝试过使用Firebug,看看你的请求被贴? – 2010-11-09 18:24:31