jquery dynamic nested list
<p>I'm sure this is easy, but I'm beating my head up against a wall.  </p>

<p>I am basically creating a dynamically generated browse tree using jQuery, JSON and PHP (based on this approach: <a href="http://www.electrictoolbox.com/json-data-jquery-php-mysql/" rel="nofollow">http://www.electrictoolbox.com/json-data-jquery-php-mysql/</a>).  I have changed the dropdown boxes into ul li menus.  On the 'a' click event, I query the database and return the values of the next set of data.  This is all working.  I'm just having trouble getting the newly returned list to "nest" under the li that was clicked.  For example:</p>

<pre><code>&lt;ul id='levelone'&gt;
 &lt;li&gt;&lt;a id='cats' href='#'&gt;Cats&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a id='dogs' href='#'&gt;Dogs&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a id='fish' href='#'&gt;Fish&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>If the user clicks on 'dogs' my PHP/JSON event queries the database and returns the list:</p>

<pre><code>&lt;ul id='leveltwo'&gt;
 &lt;li&gt;&lt;a id='hounds' href='#'&gt;Hounds&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a id='shepherds' href='#'&gt;Shepherds&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a id='poodles' href='#'&gt;Poodles&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>This works, but I want the list to display as a nested list under 'Dogs' on the page.  Like this:</p>

<pre><code>&lt;ul id='levelone'&gt;
 &lt;li&gt;&lt;a id='cats' href='#'&gt;Cats&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a id='dogs' href='#'&gt;Dogs&lt;/a&gt;&lt;/li&gt;
     &lt;ul id='leveltwo'&gt;
      &lt;li&gt;&lt;a id='hounds' href='#'&gt;Hounds&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a id='shepherds' href='#'&gt;Shepherds&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a id='poodles' href='#'&gt;Poodles&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
 &lt;li&gt;&lt;a id='fish' href='#'&gt;Fish&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>I've tried a variety of approaches, but none are working.  I'm sure there is an easy button I'm missing...Any assistance would be appreciated.</p>

<p>The jQuery to generate the leveltwo list is below:</p>

<pre><code>    function populateAmimalSubcategory() {
    $.getJSON('./includes/browsedata/animalsubcat.php', { animalcategory:       
       $('#ucHidden').val() }, function (data) {
        $("#animalsubcat").append("&lt;ul id='subcatlist'&gt;&lt;/ul&gt;");
        $.each(data, function (val, text) {
        $("#subcatlist").append("&lt;li&gt;&lt;a href='#' id='" + this.use_subcategory + "'&gt;" + this.use_subcategory + "&lt;/a&gt;&lt;/li&gt;");
        });
    });
</code></pre>

<p>This calls the function when an item in the level one div is clicked:</p>

<pre><code>    $('#animallist a').live('click', function(){
        document.getElementById('ucHidden').value = this.id;
        $('#animalsubcat').empty();
        populateAnimalSubcategory();
    });
</code></pre>

<p>KMT</p>
