<Script type = "text/javascript">
$ (Function (){
$. Ajax ({
Type: "post ",
ContentType: "application/json ",
Url: "WebService1.asmx/GetListProvince ",
Data :"{}",
Success: function (result ){
Var strDrop = '';
For (var I = 0; I <result. d. length; I ++ ){
StrDrop + = "<option value = '" + result. d [I]. provinceID + "'>" + result. d [I]. provinceName + "</option> ";
}
$ ('# Province'). append (strDrop );
}
})
$ ('# Province'). change (function (){
$ ('# City option: gt (0)'). remove ();
$ ('# Area option: gt (0)'). remove ();
$. Ajax ({
Type: "post ",
ContentType: "application/json ",
Url: "WebService1.asmx/GetListCity ",
Data: "{Id: '" + $ (this). val () + "'}",
Success: function (result ){
Var strCity = '';
For (var I = 0; I <result. d. length; I ++ ){
StrCity + = "<option value = '" + result. d [I]. cityID + "'>" + result. d [I]. cityName + "</option> ";
}
$ ('# City'). append (strCity );
}
})
})
$ ('# City'). change (function (){
$ ('# Area option: gt (0)'). remove ();
$. Ajax ({
Type: "post ",
ContentType: "application/json ",
Url: "WebService1.asmx/GetListArea ",
Data: "{Id: '" + $ (this). val () + "'}",
Success: function (result ){
Var strArea = '';
For (var I = 0; I <result. d. length; I ++ ){
StrArea + = "<option value = '" + result. d [I]. areaID + "'>" + result. d [I]. areaName + "</option> ";
}
$ ('# Region'). append (strArea );
}
})
})
})
</Script>
<Select id = "Province">
<Option> -- select -- </option>
</Select> Save
<Select id = "City">
<Option> -- select -- </option>
</Select> City
<Select id = "Area">
<Option> -- select -- </option>
</Select> County
WebService
[WebMethod]
Public List <Model. province> GetListProvince ()
{
BLL. province bll_Province = new BLL. province ();
List <Model. province> list = bll_Province.GetListModel ();
Return list;
}
[WebMethod]
Public List <Model. city> GetListCity (string Id)
{
BLL. city bll_City = new BLL. city ();
List <Model. city> list = bll_City.GetListCity ("father = '" + Id + "'");
Return list;
}
[WebMethod]
Public List <Model. area> GetListArea (string Id)
{
BLL. area bll_area = new BLL. area ();
List <Model. area> list = bll_area.GetlistArea ("father = '" + Id + "'");
Return list;
}
The layer-3 method is the same as the layer-3 method in the previous article.