This article is the use of jquery to achieve a simple AJAX implementation of a detailed analysis of the introduction, the need for friends to refer to the
-->html page
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<title> User's Famous school example </title>
<script src= ". /js/jquery-1.7.2.js "type=" Text/javascript "></script>
<script src= ". /js/verify.js "type=" Text/javascript "></script>
</head>
<body onload= "verify ()" >
Jax Example of
users ' famous schools
<!--Ajax means you do not need to use forms for data submission, so you do not have to write the form-->
<input type= "text" value= "id=" UserName "/>"
<input type= "button" value= "Submit" onclick= "/>
<!--reserved space, display results-->
<div id= "result" ></div>
<!--Div is block,but span is inline--->
</body>
</html>
->js Page
Copy Code code as follows:
function Verify () {
$ ("#userName"). KeyUp (function () {
var user = $ (this). Val ();
var userobj = $ (this);
$.post (".. /index.aspx ", {Userobj:user}, callback);
});
}
function Callback (data) {
$ ("#result"). Text (data);
}
->aspx Page
Copy Code code as follows:
<%
Response.Clear ();
String str_name = request["Userobj"];
if (Str_name = = "Xtyang")
{
Response.Write ("OK");
}
Else
{
Response.Write ("no");
}
Response.End ();
%>