jquery get image width in an ajax callback
<p>How to get image size in an ajax callback? it returns value <code>0</code>. </p>

<p>index.php</p>

<pre><code>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(document).ready(function(){
    $('#click').click(function(){
        $.ajax({
        url: "result.php", 
        dataType: "html",
        type: 'POST', 
        data: "search=robot", 
            success: function(images){ 
                $("#result").html(images);
                var width = $('#images').width();
                alert(width);
            }
        });
    });
});
&lt;/script&gt;
&lt;body&gt;
&lt;a id="click"&gt;click&lt;/a&gt;
&lt;div id="result"&gt;&lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p><code>result.php</code></p>

<pre><code>&lt;img src="http://gandt.blogs.brynmawr.edu/files/2009/01/&lt;?php echo $_POST['search']; ?&gt;.jpg" id="images" /&gt;
</code></pre>
