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