I'd like to do something like:
var content = "";
$.getJSON("/plants", function(result) {
$.each(result.plants), function() {
content += "<tr><td>"+this.plant_name+"</td></tr>";
});
});
$("#plant_table").append(content);
By the time I do the append at the last line, content
is empty. I'd guess it's because of the scope of the content
variable, but I'm unfamiliar with how to remedy this.
Thanks in advance.