Hide loader hides as soon as shown
<p>I am using simple jquery to show and hide a loader but because there is no callback as such its hiding as soon as showing. Here's the code, will comment it to explain flow:</p>

<pre><code>$('#test img').click(function(e) { // image is clicked

    $('#loader').show(); // show loader
    e.preventDefault();
    $(this).css('opacity', 1);

    var url = $('input[name=url]').val();

    var filter = $(this).data('filter');
    $('input[name=filter]').val(filter);

    // get image as a result of a call to another page
    $('#result').attr('src', 'index.php?url=' + url + '&amp;filter=' + filter);

    $('#loader').hide(); // hide loader

});
</code></pre>

<p>As you can see the image is generated from a call to another php page, which outputs the image after processing like this:</p>

<pre><code>$output = 'http://myurl.com/filter/' . $filename;
header('Location: ' . $output, TRUE, 301);
die;
</code></pre>

<p>Is there a way can I make a callback up so the loader loads when image clicked and then hides when other image created.</p>
