Ok , i found a correct way to do this. I just do my ajax request to php but set it to an sync (async false), so the dynatree code will wait for the result. Then i implemented a check around the move function of dynatree:
$.ajax({
url: "xxx,
async: false,
success: function(data){
if(data.error == 0){
showModalOk(data.message);
phpres = true;
}else
phpres = false;
}
}
});
if(phpres == true){
sourceNode.move(node, hitMode);
node.expand(true);
}
that way the node only gets moved if it's allowed, so no need to restore the node afterwards