- ·上一篇文章:Ajax中浏览器的缓存问题解决方法
- ·下一篇文章:jquery判断某个ID是否存在
AJAX和WebService实现省市县三级联动具体代码
-------------------------------------WebService1.asmx---------------------------------------
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World"
}
[WebMethod]
public List GetProvince()
{
BLL.province bpro = new BLL.province()
List list = bpro.GetListModel()
return list
}
[WebMethod]
public List GetCityByPro(string proid)
{
BLL.city bcity = new BLL.city()
List list = bcity.GetListModel("father=&apos
" + proid + "&apos
")
return list
}
[WebMethod]
public List GetAreaByCity(string cityid)
{
BLL.area barea = new BLL.area()
List list = barea.GetListModel("father=&apos
" + cityid + "&apos
")
return list
}
----------------------------------HTMLPage1.htm----------------------------
注:用到了三层架构,dal层写了一些方法
复制代码 代码如下:
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World"
}
[WebMethod]
public List
{
BLL.province bpro = new BLL.province()
List
return list
}
[WebMethod]
public List
{
BLL.city bcity = new BLL.city()
List
" + proid + "&apos
")
return list
}
[WebMethod]
public List
{
BLL.area barea = new BLL.area()
List
" + cityid + "&apos
")
return list
}
----------------------------------HTMLPage1.htm----------------------------
复制代码 代码如下:
地址 | 省 市 县 |
注:用到了三层架构,dal层写了一些方法
AJAX和WebService实现省市县三级联动具体代码