Front-end
Copy codeThe Code is 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> No title page </title>
<Style type = "text/css">
. Show {display: block ;}
. Hide {display: none ;}
</Style>
<Script type = "text/javascript" src = "jquery/jquery-1.2.6.js"> </script>
<Script type = "text/javascript">
// This method encapsulates the ajax Method for convenient calling.
Function myajax (){
$. Ajax ({
Type: 'get ',
Url: 'ajax. aspx ',
Data: 'id = 1 name = tree ',
DataType: 'html ',
BeforeSend: beforecall,
Success: callback
});
}
// Method before calling
Function beforecall (){
$ ('# Wait'). addClass ("show"). append ('calling ...');
// Alert (''); // test whether to call
}
// Callback function
Function callback (data ){
$ ('# Response'). append (data );
Certificate ('{wait'}.css ("display", "none ");
}
// Onload () event
$ (Function (){
$ ('# Confirm'). click (myajax );
})
</Script>
</Head>
<Body>
<Div id = "confirm"> click </div>
<Div id = "response"> receive background data </div>
<Div id = "wait" class = "hide"> hello </div>
</Body>
</Html>
Background
Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
Response. Write ("hello" + Request ["name"]);
Response. End ();
}