My Goal: I am writing a widget for a job which will populate a div with contents. I dont even get to execute the information as get the error:
Uncaught Syntax Error: Unexpected Token Return
I wrote an object which executes this function as follows:
function TreeView(){
this.rebuild = contructRoot();
}
function constructRoot(){
var resultant = ajax_Request();
var content = $(resultant);
var root = $("<div>");
var root_nodes = ajax_Request("/startTreeAJAX");
root_nodes.split("|");
root.html(
$("<div>").html(
$("<ul>").append($('<li>').html(root_nodes[0])).append($("<li>").html(root_nodes[1]))
)
);
root.find("li").click(function(){
clickExpand(this);
});
return root.html();
}
I am trying to essentially return the elements contents.
The closing
)of the.click()is missing, and don’t forget to close your function definition with}after thereturn. When you see a syntax error like an unexpected token, start looking to the things immediately before it to find your problem…