IE img load returns error <p>I am trying to insert an image from an ajax repsonse. Everything work, but not in IE.</p> <p>I have tried: <a href="http://stackoverflow.com/questions/12000016/image-load-not-working-with-ie-8-or-lower">Image load not working with IE 8 or lower</a>, but get "broken image".</p> <p>Tried to solve it described here: <a href="http://www.paulund.co.uk/handle-image-loading-errors-with-jquery" rel="nofollow">http://www.paulund.co.uk/handle-image-loading-errors-with-jquery</a>, but it does not solve anything. I did not attach it to the document.ready function though, since this is ajax, the IE &lt; 9 hack will never be triggered by the ajax call. the Ajax call is triggered by a mouse click which repsonds with an image link. When using JQuery's dialog function, IE does not show the image. Forcing it by right-clicking and 'Show image' shows the image.</p> <p>Anybody know how to solve this problem?</p> <pre><code>function search(url){ $.ajax({ type: "GET", url: url, dataType: "html", success: function(data, status, XMLHttpResponse){ clickListenerEvent(); }, error: function(data, textStatus, XMLHttpResponse){ alert("AJAX error"); } }); } function clickListenerEvent(){ $('a.show-image').click(function (e) { var element = $(this); var href = element.attr('href'); var title = element.attr('title'); var thisId = 'dialogbox_'; var exisitingDialog = $('.dialogbox[id='+thisId+']'); if(!exisitingDialog.length){ element.parent().append("&lt;div id='"+thisId+"'&gt;&lt;/div&gt;"); } var thisDialog = $('.dialogbox[id='+thisId+']'); var img = new Image(); $(img).load(function() { alert('successfully loaded'); }).error(function() { alert('broken image!'); //$(this).attr('src', href); }).attr('src', href); $(thisDialog).append(img); //create the dialog $('.dialogboks[id='+thisId+']').dialog({ closeText: 'Close', title: title }); if ( $.browser.msie &amp;&amp; $.browser.version &lt; 9 ) { $('img').each(function(){ $(this).attr('src', $(this).attr('src')); }); } e.preventDefault(); }); } </code></pre>