.net ajax 检测用户名是否可用代码
<script type="text/网页特效" src="css教程/jquery-1.3.2.js"></script>
<script type="text/javascript">
function judgeusername()
{
$.ajax({
type:"get",
url:"ajaxuserinfomodify.aspx",
datatype:"html",
data:"username="+$("#txtname").val(),
beforesend:function(xmlhttprequest)
{
$("#showresult").text("正在查询");
//pause(this,100000);
},
success:function(msg)
{
$("#showresult").html(msg);
$("#showresult").css("color","red");
},
complete:function(xmlhttprequest,textstatus)
{
//隐藏正在查询图片
},
error:function()
{
//错误处理
}
});
}
</script>
<div>
<input id="txtname" type="text" /><input type="button" value="查看用户名是否存在" id="btn" onclick="judgeusername();" />
<div id="showresult" style="float:left">div>
div>aspx文件
protected void page_load(object sender, eventargs e)
{
string username = request.querystring["username"].tostring ();
if (username == "james hao")
{
response.write ("用户名已经存在!");
}
else
{
response.write ("您可以使用此用户名!");
}
}