Static Page
CopyCode The 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 type = "" src = "/>
</SCRIPT>
<SCRIPT type = "text/JavaScript">
/*
Encodeuri Method
Encode the parameters passed by the URL
Encodes a text string into a valid Uniform Resource Identifier (URI ).
*/
Function createquerystring (){
VaR firstname = encodeuri ($ ("# firstname"). Val ());
VaR Birthday = encodeuri ($ ("# birthday"). Val ());
// Combine them into objects
VaR querystring = {firstname: firstname, birthday: Birthday };
Return querystring;
}
Function dorequestusingget (){
$. Get ("ajaxserve. aspx", createquerystring (),
// Send a GET request
Function (data ){
$ ("# Serverresponse" pai.html (decodeuri (data ));
}
);
}
Function dorequestusingpost (){
$. Post ("ajaxserve. aspx", createquerystring (),
// Send a POST request
Function (data ){
$ ("# Serverresponse" pai.html (decodeuri (data ));
}
);
}
</SCRIPT>
</Head>
<Body>
<H2> enter name and birthday </H2>
<Form>
<Input type = "text" id = "firstname"/> <br/>
<Input type = "text" id = "Birthday"/>
<Input type = "button" value = "get" onclick = "dorequestusingget ();"/> <br/>
<Input type = "button" value = "Post" onclick = "dorequestusingpost ();"/>
</Form>
<Div id = "serverresponse"> </div>
</Body>
</Html>
Dynamic pageCopy codeThe Code is as follows: protected void page_load (Object sender, eventargs E)
{
// Response. Write ("background data ");
If (request. httpmethod = "Post ")
Response. Write ("post:" + request ["firstname"] + ", your birthday is" + request ["Birthday"]);
Else if (request. httpmethod = "get ")
Response. Write ("Get:" + request ["firstname"] + ", your birthday is" + request ["Birthday"]);
}