I have a problem with jQuery.
I wanted to get the real width/height of an img.
Now I used this function to get it:
var imageSize = function(image) {
    var realImageSize = { };
    $("<img/>") // Make in memory copy of image to avoid css issues
    .attr("src", $(image).attr("src"))
    .load(function() {
        realImageSize.width = this.width;   // Note: $(this).width() will not
        realImageSize.height = this.height; // work for in memory images.
        alert(realImageSize['height']); // Valid height
    });
    alert(realImageSize['height']); // Undefined
    return realImageSize;
}
So I'm copying the image in memory, and then I get and set the images real size in the .load method. 
Now, the problem is that the var realImageSize variable isn't available in this scope for some reason. Can anyone tell me why?
 
     
     
     
    