[jQuery] Finding the size of an image

[jQuery] Finding the size of an image

<html>
<body>
Hello folks,
I am wanting to find the width of an image loaded via an ajax call so
that I can alter the width of a div holding the caption for that
image.
The image that is loaded is always tagged with an id of 'theImage'. 
Each image loaded with each ajax call has a slightly different
width.
The fitCaption function below doesn't work and I don't understand why -
can someone help me please?
<tt>function getNextPage(ej) { 
   
$.get("scripts/ajax_ramosus_client_second.asp?brm="+ej
+"&q="  + new Date().getTime(),
function(responseText){
       
$("#wrapper").html(responseText); 
        fitCaption();
        });  
};
function fitCaption(){
    var img_width=50;
    if (($('#theImage').length>0)) {
        img_width =
$('#theImage').width();
    };
    alert (img_width);
   
$("#sCaption").css("width",img_width);
}
</tt>The alert call displays 0 all the time.
My mistake is???
Thanks,
Bruce</body>
</html>