這裏是什麼對我的作品:
解決方案1:從靜態HTML 的javascript:在發送方:
function onBeforeLoad (node, data)
{
data.Name=name;
}
HTML在發送方:
<ul id="ScriptTree1" class="easyui-tree" lines="true" data-options="onBeforeLoad:onBeforeLoad, lines:true, processData:false" url="someural.php"/>
解決方案2:來自動態代碼: HTML
<ul id="ScriptTree2" class="easyui-tree" animate="true"></ul>
JavaScript函數觸發任何具體事件:
function filltree()
{
$('#ScriptTree2').tree
({
dataType:'json',
method:'POST',
lines: true,
processData:false,
onBeforeLoad: function (node,param) { param.Name=name; return true;},
onLoadError: function (dom)
{
if (!String.prototype.trim)
{
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g, '');};
}
var sResponse = new String (arguments[0].responseText);
alert ('Compl: ' + arguments[1] + ' ' + arguments[2].description + ' ' + arguments[2].name + '\r\nAnswer:\r\n' + sResponse.trim() + '\r\nQuery: \r\n' + decodeURIComponent(arguments.caller.caller.caller[0].data));
return true;
},
url:'someurl.php'
});
}
和被調用腳本: someurl.php
<?
if ($_POST['Name'] != '') {$Name=$_POST['Name'];} else {$Name='';};
if ($_POST)
{
$kv = array();
foreach ($_POST as $key => $value)
{
$kv[] = "$key=$value";
}
$query_string = join(" | ", $kv);
}
echo '[{"id":100,"text":"params","state":"open","children":[{"id":104,"text":"query_string: '.$query_string.'","state":"open"}]}]';
?>
請發表您的代碼。 – 2012-01-31 14:30:10
以下是全部功能: onExpand:function(node){alert(「inside expand」); var nodeId = node.id; url:'/ webapp/fetchdata?nodeId ='+ nodeId; } – user1126136 2012-01-31 14:59:06
在你的更新代碼中,這行不做任何事情:'url:'/ webapp/fetchdata?nodeId ='+ nodeId;'它所做的只是創建一個[label](https://developer.mozilla.org/en/) JavaScript/Reference/Statements/label)稱爲'url',然後連接兩個字符串,並對結果不做任何處理。我認爲你需要展示更多的代碼才能獲得有意義的答案。 – 2012-01-31 15:59:17