Get height and width of ajax response

Get height and width of ajax response

I have a script which sends an ajax request and the appends the data to a div which needs to change it's height and width depending on the content returned.

So far I have

  1.         $.ajax({
  2.               url: url,
  3.               success: function(data) {
  4.                     target.html(data);
  5.                    
  6.                     var contentWidth = target.width();
  7.                     var contentHeight = target.height();
  8.                    
  9.                     alert(contentWidth + ', ' + contentHeight);
  10.               }
  11.         });
However this doesn't return the new width and height it just returns the previously set css values.

Does anyone know how to acheive this?

Thanks for any help