$("li").click(function() {
var uid = $(this).attr('uid');
// pass the uid to the next page and get the response
var response = functionName(uid);// some function call back to get the <ul> corresponding to that li uid
// Now add the response which is a ul to the li
if($(this).find('ul').length===0) {
$(this).append(response);
}
// insert your response there
});
As per your code
$(document).ready(function(){
$("li").click(function(){
var self = this;
var val = $(this).attr("uid");
$.post("tree-process.php",{val:val},function(response){
if($(self).find('ul').length===0) {
$(self).append(response);
}
});
});
});