2017-6-6 Ajax version of the page no refresh level three linkage

Source: Internet
Author: User

Tag: Refresh UI using COM build ISP color error code

Implementation results:

Page code:

<div><SelectId="Sel1"style="width:100px;"> </Select> <SelectId="Sel2"style="width:100px;"> </Select> <SelectId="Sel3"style="width:100px;"> </Select> </div>

JS Code:

Change1); function Change (a) {if(A = ="1"{$.ajax ({URL:"select.ashx", data: {"Code":"0001"}, type:"Post", DataType:"JSON", Success:function (msg) {$ ("#sel1"). HTML ("");  for(Iinchmsg) {                                              varstr ="<option value= '"+ Msg[i].code +"' >"+ Msg[i].name +"</option>"; $("#sel1"). append (str); } Change (2); }, Error:function () {alert ("AAA"); }, Beforesend:function () {$ ("#sel1"). HTML (""); varstr ="<option value= ' null ' > Data loading ...</option>"; $("#sel1"). append (str);        }            }); }        if(A = ="2"{$.ajax ({URL:"select.ashx", data: {"Code": $("#sel1"). Val ()}, type:"Post", DataType:"JSON", Success:function (msg) {$ ("#sel2"). HTML ("");  for(Iinchmsg) {                                                varstr ="<option value= '"+ Msg[i].code +"' >"+ Msg[i].name +"</option>"; $("#sel2"). append (str); } Change (3); },                //If the pop-up window jumps, the server side is wrong, the server does not return the specified JSON data format .error:function () {alert ("AAA"); },                //execute when the server is requested (either right or wrong) at the beginning of the load data will be executedBeforesend:function () {$ ("#sel2"). HTML (""); varstr ="<option value= ' null ' > Data loading ...</option>"; $("#sel2"). append (str); },                //after processing is complete, the data is loaded and executed regardless of whether it is returned to sussess or errorcomplete:function () {}}); }        if(A = ="3"{$.ajax ({URL:"select.ashx", data: {"Code": $("#sel2"). Val ()}, type:"Post", DataType:"JSON", Success:function (msg) {$ ("#sel3"). HTML ("");  for(Iinchmsg) {                                               varstr ="<option value= '"+ Msg[i].code +"' >"+ Msg[i].name +"</option>"; $("#sel3"). append (str); }}, Error:function () {}, Beforesend:fu Nction () {$ ("#sel3"). HTML (""); varstr ="<option value= ' null ' > Data loading ...</option>"; $("#sel3"). append (str);        }            }); }    }    $("#sel1"). Change (function () { change (2);    }); $("#sel2"). Change (function () { change (3); });
three-level linkage JS code

General Handler code:

using(Citydataclassesdatacontext con =NewCitydataclassesdatacontext ()) {StringBuilder str=NewStringBuilder (); Str. Append ("["); stringAA = context. request["Code"]; intCount =0; List<ChinaStates> clist = con. Chinastates.where (R=>r.parentareacode = =aa).            ToList (); foreach(Chinastates Chinchclist) {                if(Count >0) {str. Append (","); } str. Append ("{\ "name\": \ ""+ch. areaname+"\ ", \" code\ ": \""+ch. Areacode+"\"}"); Count++; } str. Append ("]"); Context.            Response.Write (str); Context.        Response.End (); }

2017-6-6 Ajax version of the page no refresh level three linkage

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.