栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SSH结合jquery实现三级联动效果

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SSH结合jquery实现三级联动效果

本文实例为大家分享了jquery实现三级联动的具体代码,供大家参考,具体内容如下

jsp页面部分:

 
  • 选择楼栋:
  • 选择住房:
  • js部分:

      function floor(){
    
        document.getElementById("build").options.length =0;
        document.getElementById("floot2").options.length =0;
        var parentId = document.getElementById("village").value;
    
        if(parentId == 0){
    
        }else{
          $.ajax({
     type : "post",
     url : "floor.action",
     data: {"parentId":parentId},
     dataType : "json",
     success :function(data){
    
       console.log(data);
       var len = data.length;
    
       var htm = "";
       for(var i=0;i"+data[i].info+"";
       }
    
       $("#build").append(htm);
     }
          })
        }
      }
    
      function floor2(){
        document.getElementById("floot2").options.length =0;
        var build = document.getElementById("build").value;
    
        if(build == 0){
    
        }else{
          $.ajax({
     type : "post",
     url : "floor2.action",
     data: {"parentId":build},
     dataType : "json",
     success : function(data){
       var len = data.length;
       var htm = "";
       for(var i=0;i"+data[i].info+"";
       }
       $("#floot2").append(htm);
     }
          })
        }
      }
    
    

    struts2配置部分:

    
        
          
     floor
          
        
    
        
          
     floor2
          
        
      
    
    

    action部分:

    public String floor(){
        System.out.println("这里是ajax调用");
        //floor = addressInfoService.getFloor(addressInfo.getParentId());
        System.out.println(addressInfo.getParentId());
        floor = addressInfoService.getFloor(addressInfo.getParentId());
        return SUCCESS;
      }
    
      public String floor2(){
        System.out.println("这里是ajax的第二次调用");
        System.out.println(addressInfo.getParentId());
        floor2 = addressInfoService.getBuild(addressInfo.getParentId());
        return SUCCESS;
      }
    
    

    最后,一定不要忘记导入struts2-json-plugin-2.3.15.1.jar 这个夹包的版本也要和struts2的其他的夹包的版本一致。

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

    转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/148130.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号