Using jquery to implement simple Ajax

Source: Internet
Author: User
Tags html page
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 ();
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.