jquery ajax Local No refresh update data implementation case _jquery

Source: Internet
Author: User

The page to update

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></title>

<script src= "Js/jquery.js" type= "Text/javascript" ></script>

<body>
<select id= "Lucky1" onchange= "return Duoduo ();" >
<option value= "1" > Phase I </option>
<option value= "2" > Phase II </option>
</select>
<div id= "Duoduo" >
Hello </div>
<input type= "text" id= "Duo"/>
</body>

<script type= "Text/javascript" >

function Duoduo () {
$.ajax ({
Type: ' Post ',//optional get
URL: ' ajax.aspx ',//Here is the program to receive data
Data: ' Data= ' + $ ("#lucky1"). Val (),//Pass to PHP, multiple parameters & connection
DataType: ' HTML ',//server returned data type optional XML, Json jsonp script HTML text, etc.
Success:function (msg) {
Here is the data processing function returned by the program after the success of the Ajax commit. MSG is the returned data, and the data type is defined in the datatype parameter!
Document.getelementbyidx_x_x ("Duoduo"). InnerHTML = msg;
$ ("#duoduo"). InnerHTML = msg;
},
Error:function () {
Alert (' Sorry for failure ');
}
})
}

</script>


Action Page
Copy Code code as follows:

protected void Page_Load (object sender, EventArgs e)
{
if (request.params["data"). ToString (). Equals ("1"))
{
Response.Write ("<a href=\" http://www.baidu.com\ "> Phase I </a>");
}
else if (request.params["data"). ToString (). Equals ("2"))
{
Response.Write ("<a href=\" http://www.baidu.com\ "> Phase 2nd </a>");
}
}

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.