Static 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 ">
<title> Untitled Page </title>
<script type= "Text/javascript" src= "Jquery/jquery.js" >
You can't use <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 ());
Grouped into the form of an object
var querystring={firstname:firstname,birthday:birthday};
return querystring;
}
function Dorequestusingget () {
$.get ("Ajaxserve.aspx", createquerystring (),
Send a GET request
function (data) {
$ ("#serverResponse"). HTML (decodeURI (data));
}
);
}
function Dorequestusingpost () {
$.post ("Ajaxserve.aspx", createquerystring (),
Send POST request
function (data) {
$ ("#serverResponse"). HTML (decodeURI (data));
}
);
}
</script>
<body>
<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>
Dynamic page
Copy Code code 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"]);
}