jQuery: Resizing an image after loading - resizing already works, but is not triggered
<p>I'd like to show an image as big as possible. When the user is clicking it in the galerie, it'll be loaded via ajax and should be resized. Again, the resizing isn't the problem, if I'm using it by a click-event, it works perfectly, but it's not correctly triggered, if I include it like this:</p>

<pre><code>$('.thumbnail').click(function() { 
  id = $(this).attr('id');
  $('#picbox').fadeIn(fadeSpeed);
  $('#picture').load("/propfe/ajax/picture/" + id);
  $('#picture').fadeIn(fadeSpeed);

  $('#bigpic').ready(function() {
    var browserHeight = $(window).height() - 200;
    var browserWidth = $(window).width() - 200;
    var height = $('#bigpic').height();
    var width = $('#bigpic').width();

    var picRatio = width / height;
    var windowRatio = browserWidth / browserHeight;

    if(picRatio &lt; windowRatio) {
        $('#bigpic').css({ "height": browserHeight + "px" });
    }
    if(picRatio &gt; windowRatio) {
        $('#bigpic').css({ "width": browserWidth + "px" });
    }

  });

  $('.pic_loader').fadeOut(fadeSpeed, function() {
     $('.pic_loaded').fadeIn(fadeSpeed);
  });
});
</code></pre>

<p>So far, I think I'll explayn it shortly, maybe you don't really have to read this paragraph: The code is triggered by clicking on the thumbnail. First, it gets the id of the picture, that should be loaded and fades in the div, everything will be loaded in and with a loading-gif. After that, the ajax-request will be send, the result will be faded in and when it's ready, the image (id=bigpic) should be resized. The last lines aren't very interesting, they just fade out the loading-gif and fading in all the rest, the code is generating.</p>

<p>When I tried to give out some variables, the alert is given before anything is faded in and the width and the height of the picture is null, so I think, the code is triggered before the picture is loaded.</p>

<p>So how is it possible, it is just executed, if the image is fully loaded?</p>
