Instance:
1. Request Ajax. aspx
Html Code
Copy code The Code is as follows: <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>
JS Code copy Code the code is as follows:
2. Page ajaxuserinfomodify. aspx
Background codeCopy codeThe Code is as follows: 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! ");
}
}
3 , Running interface
(1) initialization Interface
(2) Querying the prompt page
(3) Verify that the user name already exists on the page
(4) The verification user name does not exist on the page
So far, Ajax has completed the function of verifying whether the user name exists.