日期:2014-05-19  浏览次数:20925 次

关于dtree结合dwr做导航树错误 代码如下
<%@ page language="java" contentType="text/html; charset=gb2312"
  pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>导航栏</title>
<script type="text/javascript" src="JS/mydtree.js"></script>
<link rel="StyleSheet" type="text/css" href="css/dtree.css" >
<link rel="StyleSheet" type="text/css" href="css/leftStyle.css" >
<script type='text/javascript' src='dwr/engine.js'></script>
  <script type='text/javascript' src='dwr/interface/SjzdflDAO.js'></script>  
</head>
<body>
<p><a href="javascript: d.openAll();">打开全部</a> | <a href="javascript: d.closeAll();">关闭全部</a></p>

<script type="text/javascript">
<!--
var sjzdflArr;
alert("11");
//设置为同步
DWREngine.setAsync(false);
alert("12"); 
SjzdflDAO.findAll(load);
//重新设置回异步
alert("13"); 
DWREngine.setAsync(true); 
function load(data){

sjzdflArr = data;

}

var d = new dTree('d');
d.config.useCookies = false;//不使用cookies
d.config.useStatusText = true; //状态栏显示文本
d.config.closeSameLevel = true; //关闭同一层次其他节点
//root
d.add(0,-1,"客户关系管理系统");

//一级导航
d.add(1,0,"客户信息");
d.add(2,0,"客户服务");
d.add(3,0,"日程/任务");
d.add(4,0,"项目管理");
d.add(5,0,"系统管理");
d.add(6,0,"数据字典");
d.add(7,0,"消息提醒");

d.add(11,1,"客户","http://www.sina.com");
d.add(12,1,"联系人","http://www.sina.com");

d.add(21,2,"客户投诉","http://www.sina.com");
d.add(21,2,"投诉报表","http://www.sina.com");

d.add(31,3,"日程","http://www.sina.com");
d.add(32,3,"任务","http://www.sina.com");

d.add(41,4,"项目立项","http://www.sina.com");
d.add(42,4,"项目审批","http://www.sina.com");
d.add(43,4,"项目进程","http://www.sina.com");
d.add(44,4,"项目总结","http://www.sina.com");
d.add(45,4,"项目交易","http://www.sina.com");

d.add(51,5,"用户","http://www.sina.com");
d.add(52,5,"角色","http://www.sina.com");

for(var i = 0; i < sjzdflArr.length ;i++) {
d.add(61 + i,6,sjzdflArr[i].sjzdflmc);
}

d.add(71,7,"短消息","http://www.sina.com");

document.write(d);
-->
</script>


</body>
</html>

当程序走到alert("12"); 之后就不走是怎么回事?

------解决方案--------------------
不走了?
看不出具体问题
------解决方案--------------------
//设置为同步
DWREngine.setAsync(false);
alert("12");
SjzdflDAO.findAll(load)

换个顺序:


//设置为同步
DWREngine.setAsync(false);
SjzdflDAO.findAll(load)
alert("12");