How do I wait for multiple jquery posts to complete?
<p>I'm trying to clear a busy icon and re-enable my delete button once the multiple jquery posts have completed.  Here is my current code:</p>

<pre><code>    $('#deleteimgs').live('click', function(e) {
        e.preventDefault();

        if ($('input[name="chk[]"]:checked').length &gt; 0 ) {

            $('#deleteimgs').button('loading');
            $('#saveicon').show();

            var boxes = $('input[name="chk[]"]:checked');
            $(boxes).each(function(){

                 var id = $(this).attr('id').substr(7);
                 var self = this;

                 $.post("/functions/photo_functions.php", { f: 'del', imgid: id}, function(data){
                    if (data.success) {
                        $(self).hide();
                        $("#img_"+id).hide(250);
                    }
                }, "json");
            });

            $('#saveicon').hide();
            $('#deleteimgs').button('reset');
        }

    });
</code></pre>

<p>My hide call and reset call are being trigger prior to completion of the foreach loop.  Is there a way to wait for completion before making these two calls?</p>

<pre><code>$('#saveicon').hide();
$('#deleteimgs').button('reset');
</code></pre>
