论坛首页 入门技术论坛

DWR中无法触发回调函数

浏览 2300 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-03-05  
DWR
今天我用DWR2结合SPRING2.5来做三级联动时,可以执行到后台的方法,并且也有返回值,但是就是不能触发回调函数。以下是我的dwr.xml
<create creator="new" javascript="CategoryManager">  
      <param name="class" value="com.muddy.web.service.impl.CategoryManagerImpl"/>
      <include method="getCategoryById"/>
        </create>
        <convert match="com.muddy.web.model.Category" converter="bean"></convert>

以下是JSP页面的JS方法:

      function getCity(){
            var obj_Pro = document.getElementById("sel_Pro");  
            var obj_City = document.getElementById("sel_City");  
            var obj_County = document.getElementById("sel_County");  
            var pro_Index = obj_Pro.selectedIndex;  
            var pro_Value = obj_Pro.options[pro_Index].value;
            alert(pro_Value); 
            if(pro_Value != "" && pro_Value != null){
                CategoryManager.getCategoryById(pro_Value,cityReturn);
            }else{  
                DWRUtil.removeAllOptions(obj_City);  
                DWRUtil.addOptions(obj_City,{'':'please select'});  
                DWRUtil.removeAllOptions(obj_County);  
                DWRUtil.addOptions(obj_County,{'':'please select'});  
            }  
        }
    // callback math
        function cityReturn(data){
        alert("test");
            var obj_City = document.getElementById("sel_City");  
            DWRUtil.removeAllOptions(obj_City);  
            DWRUtil.addOptions(obj_City,{'':'please select','4':'sasdfsa'});
            for(var i=0;i<data.length;i++){
            DWRUtil.addOptions(obj_City,{'aaaaas':'aaa'});
            }
        }

请有经验的帮忙解决一下。谢谢!
   发表时间:2008-03-12  
CategoryManager.getCategoryById(pro_Value,function(data) {
cityReturn(data); });
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics