<%@ page language= "C #" contenttype= "text/html" responseencoding= "gb2312"%>
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>jquery Verify user name (Ajax verifies user name exists) </title>
<script type= "text/web Effects" src= "CSS Tutorial/jquery-1.3.2. Web Effects" ></script>
<script type= "Text/javascript" >
function Judgeusername ()
{
$.ajax ({
Type: "Get",
URL: "www.111cn.net.asp tutorial X",
DataType: "HTML",
Data: "Username=" +$ ("#txtname"). Val (),
Beforesend:function (XMLHttpRequest)
{
$ ("#showresult"). Text ("Query Now");
Pause (this,100000);
},
Success:function (msg)
{
$ ("#showresult"). HTML (msg);
$ ("#showresult"). CSS ("Color", "red");
},
Complete:function (Xmlhttprequest,textstatus)
{
Hide query Picture
},
Error:function ()
{
Error handling
}
});
}
</script>
<body>
<div>
<input id= "txtname" type= "text"/><input type= "button" value= "to see if the username exists" id= "btn" onclick= "Judgeusername ();" />
<div id= "Showresult" style= "Float:left" ></div>
</div>
</body>
<%
protected void Page_Load (object sender, EventArgs e)
{
String username = request.querystring["username"].tostring ();
if (username = "James Hao")
{
Response.Write ("User name already exists!") ");
}
Else
{
Response.Write ("You can use this username!") ");
}
}
/*
Asynchronous refresh implementation has a variety of ways, but also the use of a variety of JS framework, the following is implemented using the jquery framework Ajax to verify the existence of the user name
*/
%>