Asp tutorial. net ajax check whether the user name is available
<Script type = "text/webpage effects" src = "css tutorial/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 ("querying ");
// Pause (this, 100000 );
},
Success: function (msg)
{
$ ("# Showresult" cmd.html (msg );
$ ("# Showresult" ).css ("color", "red ");
},
Complete: function (xmlhttprequest, textstatus)
{
// Hide the picture being queried
},
Error: function ()
{
// Handle errors
}
});
}
</Script>
<Div>
<Input id = "txtname" type = "text"/> <input type = "button" value = "check whether the user name exists" id = "btn" onclick = "judgeusername (); "/>
<Div id = "showresult" style = "float: left"> div>
Div>
Aspx file
Protected void page_load (object sender, eventargs e)
{
String username = request. querystring ["username"]. tostring ();
If (username = "james hao ")
{
Response. write ("the user name already exists! ");
}
Else
{
Response. write ("You can use this user name! ");
}
}