下面是代码。主要是验证用户名存在与否的!!原文出自:http://www.jb51.net/article/26741.htm
<script type="text/javascript" src="CSS/jquery-1.3.2.js"></script>
<script type="text/javascript">
function JudgeUserName()
{
$.ajax({
type:"GET",
url:"AjaxUserInfoModify",servlet的映射路径
dataType:"html",
data:"userName="+$("#txtName").val(),传给servlet的变量username
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" οnclick="JudgeUserName();" />
<div id="showResult" style="float:left">div>
div>