jQuery: How to get return value of function as value of id attribute?
<p>I'm trying to create a new tr element and set it's id attribute to the last id in the table of my MySQL db.</p>

<p>Here's what I have, but this does not set the id properly:</p>

<pre><code>$('&lt;tr&gt;').html(response)
.attr('id',function(){  
    var daId;
    $.get(
        '/getlastid.php',
        null,
        function(response){
            daId = response;
            alert(daId); //this shows correct id from db
        });
    return daId;
})
.prependTo('#table-id tbody'); //the tr does not have the id attribute set
</code></pre>

<p>How can I get this working right?  The alert proves that my server side code is correct, it's just that the id attribute is not being created for the new row.</p>
