title: Passing parameters to jquery .load callback function in a loop
body: <p>I am trying to load an set of images and apply different styles to each one as the load in. When I run my code I only get the last set of styles passed in to be applied to all images. </p>
  
  <p>For a group of images ids $foo load that image into its own box and then apply a height.</p>
  
  <pre><code>for ( var i = 0; i &lt; $foo.length; i = i + 1 ) {
    $bar = i;
    $('.box'+[i]).load('/getimage/'+$foo[i]', function(){style($(this), $bar);}
  }
  
  function style(img, $bar){
   img.css('height', $bar);
  }
  </code></pre>
  
  <p>Each image I format with the style function only gets set to height of last value of $bar.</p>
  
  <p>I want to set the height to whatever the value of $bar is at the time that image is loaded. </p>