//添加节点按钮
function add(){
opt='new';
//alert('1');
if(tree!=null&&typeof(tree)!='undefined'){
//alert('2');
var id=tree.getSelectedItemId();
if(id==''){
alert('请您选择分类节点后再做此操作!');
return ;
}
var Status=tree.getUserData(id,'status');
if(Status==0){
alert('该节点已停用,请您选择其他节点!');
return;
}
//alert('3');
setValue('capitalName','');
setValue('capitalNo','');
var form=document.getElementById('iForm');
//alert('4');
form.style.display='block';
}
}//确认按钮
function ok(){
var isOk = '';
if(tree != null && typeof(tree) != 'undefined'){
if(opt == 'new'){
var form=document.getElementById('iForm');
form.style.display='none';
isOk == executeSave();
alert('isOK'+isOk);--------------------------------------执行玩方法后,isOk取不到值
if(isOk == true){
alert('添加成功!');
}}
if(opt == 'edit'){
isOk = executeUpdate();
alert(isOk);------------------------------------1
if(isOk == 'true')
alert('修改成功!');
}
opt='';
var form=document.getElementById('iForm');
form.style.display='none';
}
}
//执行保存功能操作
function executeSave(){
if(tree != null && typeof(tree) != 'undefined'){
var id = tree.getSelectedItemId();
var capitalNo = tree.getUserData(id,"capitalNo");
var data = { capitalNo: capitalNo,// getValue("capitalNo")
capitalName: getValue("capitalName"),
parentId: id,
isEnd: "0",
status: "1"
};
pdCapital.addPdCapital(data,function(pdCapital){
if(pdCapital != null){tree.insertNewItem(id,pdCapital.capitalId,getValue("capitalName"));
tree.setUserData(pdCapital.capitalId,'capitalNo',pdCapital.capitalNo);
// alert('pdCapital.capitalNo'+pdCapital.capitalNo);
tree.setUserData(pdCapital.capitalId,'capitalName',pdCapital.capitalName);
tree.setUserData(pdCapital.capitalId,'parentId',pdCapital.parentId);
tree.setUserData(pdCapital.capitalId,'isEnd',pdCapital.isEnd);
tree.setUserData(pdCapital.capitalId,'status',pdCapital.status);var selectIdIsEnd = tree.getUserData(id,'isEnd')
if(selectIdIsEnd == '0'){
tree.setUserData(id,'isEnd',1);
return ;
}
  alert(‘success‘);------------------------------此处有结果
return true; ----执行完后返回true 
}else{
alert('执行保存失败!');
}});
}
}jsp部分
<div class="dialog-toolbar">
<a href="javascript:void(0)" onclick="add();" class="l-btn">添加</a>
</div>
<input type="button" value="确定" onclick="ok();" />