Jquery Ajax Project Development Summary

Source: Internet
Author: User

I. Function Overview: it is actually a very simple two-level drop-down list linkage.

 

Ii. Development details:

 

1. Use jquery Ajax on the information_create.aspx page to implement two levels of association in the drop-down list. This page is implemented as follows:

 

Step 1: Introduce the jquery package. Code: <SCRIPT src = "../JS/jquery. js" type = "text/JavaScript"> </SCRIPT>

 

Step 2: add three controls (two dropdownlist for association and one hiddenfield for saving the selected value). Code:

<TD>
Channel/topic:
</TD>
<TD>
<Asp: dropdownlist id = "ddlchannel" runat = "server"> </ASP: dropdownlist>

& Nbsp;

<Asp: dropdownlist id = "ddlsection" runat = "server" onchange = "GetType ()">
<Asp: listitem value = ""> select </ASP: listitem>
</ASP: dropdownlist>

<Asp: hiddenfield id = "hidtype" runat = "server"/>

</TD>

 

Step 3: Compile jquery JS Code:

<SCRIPT type = "text/JavaScript">
$ (Document). Ready (function (){
$ ('# Ddlchannel'). Change (function () // register the ddlchannel change event
{
$. Get (// call get in jquery Ajax
'../Plug/ajaxrequest. aspx', // The first parameter indicates the page to be requested
{
Type: $ ("# ddlchannel"). Val (), // The second parameter indicates the parameter to be sent to the request page. You can use request ["type"] and request ["state"] On the request page.
State: 1
},
Function (data) // The third indicates a function to obtain data.
{
$ ("# Ddlsection"). Empty (); // clear the ddlsection
$ (Data). appendto ("# ddlsection") // use the appendto data to append to the ddlsection control.
}
);
});
});
 
// This is a hidden control. When the second dropdownlist is in onchange, the value is saved to the hidden control.
Function GetType ()
{
$ ("# Hidtype"). Val ($ ("# ddlsection"). Val ());
}
</SCRIPT>

 

2. The ajaxrequest. ASPX page is an Ajax request page. In order to use this request page in the future, the service is matched by passing different state parameters. Code:

// Obtain the type. In this way, different states can be passed when the service cannot be used on multiple pages in the future, which are matched by the switch.
State = int. parse (request ["state"]. tostring ());

Switch (state)
{
Case 1:
// Set Data
Break;
Case 2:
// Set Data
.
.
.
}

Note: This is only one of my jquery Ajax projects. For more information, see the jquery API address in my downloads:

Http://download.csdn.net/source/2423908

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.