项目使用struts2+json+jquery。
网页中包含一个隐藏的DIV(ID为tt2),点击按钮“TREE”时显示DIV,并且在DIV中加载树形结构,基本代码如下:
$('#tt2').tree({
                method:'post',
                url: 'getTreeData.action',
onClick:function(node){
$(this).tree('toggle', node.target);
},
});
在网页中点击按钮“TREE”时一切正常,但是刷新网页后再执行同样操作时,DIV虽然可以显示,但是看不到其中的树形结构。调试发现getTreeData.action确实执行了,也返回了树形的数据。
因为getTreeData.action每次执行后返回的是同样的数据结果,所以怀疑是浏览器端缓存的问题。但是加了语句cache:false和jQuery.ajaxSetup({cache:false}),也给getTreeData.action后加了“?num=Math.rand”之类的字符串,然而问题依旧。
请教各位:究竟是什么原因?

解决方案 »

  1.   


    <input type="button" id="show" value="Tree"/>
    <div id="tree" class="nav-item" fit="true" style="width:200px;display:none;" border="false">
       <ul id="tt2"></ul>
    </div>$(document).ready(function(){
       $('#tt2').tree({
         method:'post',
         url: 'getTreeData.action',
         onClick:function(node){
            $(this).tree('toggle', node.target);
         }
       });   $("show").click(function(){
           $("#tree").show();
       });
    });
    });
      

  2.   

    问题已经解决,js没有问题,是搭档的Java代码有问题
    结贴了,感谢大家的关注。