How do I create a table dynamically upon getting a successful ajax response?
<p>I'm returning data from our database and creating a table dynamically. If the call to page1.php is successful, we create a table with one header row and then loop through the results and make some rows. How do I add a single header row? thx!</p>

<pre><code>$.post("page1.php", {user: "homer"}, 
function(data){
// output the header row
  function(test){
  var tblHdr ='&lt;th&gt;'+'Username'+'&lt;/th&gt;';
  $(tblHdr).appendTo("#tble");
  };

// output the user data
   $.each(data.userdata, 
     function(i,details){

     var tblRow ='&lt;tr&gt;'+'&lt;td&gt;'details.name+'&lt;/td&gt;'+'&lt;/tr&gt;';
         $(tblRow).appendTo("#tble");

    });
   }, "json"
);
</code></pre>
