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>
<Script type = "text/javascript" src = "jquery/jquery. js"> </script>
<Script type = "text/javascript">
// This method encapsulates the ajax Method for convenient calling.
Function myajax (){
$. Ajax ({
Type: 'get ',
Url: 'ajax. aspx ',
Data :'',
DataType: 'html ',
Success: callback
});
}
// Callback function
Function callback (data ){
$ ('# Response'). append (data );
}
// Onload () event
$ (Function (){
$ ('# Confirm'). click (myajax );
})
</Script>
</Head>
<Body>
<Div id = "confirm"> click </div>
<Div id = "response"> receive background data </div>
</Body>
</Html>
Background
Copy codeThe Code is as follows:
Using System;
Using System. Data;
Using System. Configuration;
Using System. Collections;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Public partial class ajax: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Response. Write ("hello ");
Response. End ();
}
}