Dipal Mehta
Dipal Mehta

Reputation: 462

MVC4 render image with Ajax call

Masters,

I have a scenario where i have a list of Items and on clicking single item it gets details along with image src url using ajax call.

I want to display(render) image right on page.

Now Image source URL is a FileActionResult returning Base64 string.

The problem is the page does not render image although it is having correct Src URL. And I don't want any additional Ajax call.

Please Help. Thanks in advance.

Upvotes: 2

Views: 520

Answers (1)

Dan Esparza
Dan Esparza

Reputation: 28367

How are you forcing the image to be updated?

The DOM is going to keep the image the same until you tell it to refresh the image -- I would suggest using something like

document.getElementById('theImg').src="/newImg.gif?unique=someuniquestring"; 

where someuniquestring is a new random datetime or something (to make sure browsers like IE don't cache the GET request).

Upvotes: 1

Related Questions