views:

33

answers:

2

I am using Visual studio 2008 in Windows 7. After an ajax call, I am building an image markup dynamically and setting it to a div like this.

var imageLocation="<%= Url.Action("Show", "Images", new { Id = Model.LoginUser.UserId })%>";
var markup = '<img  class="profile-Image" src="' + imageLocation + '"/>';

$('.divImgdisplay').html(markup);

The variable imageLocation is pointing to proper URL. When this markup is set to div element, it is not loading the image in IE 8 and in IE8 compatible mode. But firefox it is loading the image. After debugging we found that server is not receiving the request for image from the IE. Can you please help us.

+1  A: 

What if you do it like this:

$('<img class="profile-Image" />').attr('src', imageLocation).appendTo( $('.divImgdisplay') );

or

$('.divImgdisplay').append( $('<img class="profile-Image" />').attr('src', imageLocation) );
Mikael Svenson
A: 

Maybe it helps, to set the imageLocation like this:

$('.divImgdisplay img').attr('src', imageLocation);
JochenJung