您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

AJAX二级联动有哪些实现方法

2025/12/23 13:27:18发布40次查看
这次给大家带来ajax二级联动有哪些实现方法,ajax二级联动实现的注意事项有哪些,下面就是实战案例,一起来看一下。
后台handler.ashx
<%@ webhandler language="c#" class="handler" %> using system; using system.web; using system.data; public class handler : ihttphandler {  common coobj = new common();  public void processrequest(httpcontext context)  {   if (context.request.params[n] != null)   {    string num = context.request.params[n].tostring();    context.response.contenttype = text/plain;    string str = select * from address where a_num2= + num;    datatable dt = coobj.gettable(str);    string json = jsonhelper.datatabletojson(dt);    context.response.write(json);   }  }  public bool isreusable  {   get   {    return false;   }  } }
前台dropdownlist.html
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>dropdownlit </title> <meta name="generator" content="editplus" /> <script type="text/javascript" src="js/jquery-1.5.2.js"></script> <script type="text/javascript">  $(function(){    initdata(0);  });  function initdata(n)  {    $.ajax({    type:post,    datatype:json,    url: handler.ashx,    data:{n:n},    success:function(json){     $.each(json,function(i,n){      var pro=$(#dl1);      $(+ n.a_name +).appendto(pro);     });    }   });  }  function getcity(n)  {   var city=$(#dl2);   city.html();    $.ajax({    type:post,    datatype:json,     url: handler.ashx,    data:{n:n},    success:function(json){     $.each(json,function(i,n){      $(+ n.a_num1 +>+ n.a_name +).appendto(city);     });    }   });  } </script> </head> <body>  <select id="dl1" onchange="getcity(this.value)">  </select>  <select id="dl2">  </select> </body> </html>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery监控文本框事件并处理步骤详解
ajax使用代理,jsonp,xhr2实现跨域
以上就是ajax二级联动有哪些实现方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product