Jonathan Pantall
Jonathan Pantall

Reputation: 119

Setting Image Source using Jquery not working

My razor call for setting an image source works. My jQuery method returns data as a garbled url: ����

My HTML code works on page refresh:

<img id="profileWindowPictureContent" src="@Url.Action("GetLargeProfilePic", "Home")"/>

My jQuery code:

$.get("Home" + "GetLargeProfilePic", function (data) {
                        $("#profileWindowPictureContent").attr("src", data);
                    });

My controller returns a byte array:

return File(ImageToByte(bitmap1), "image/png");

I'm wondering why my jQuery code doesn't work because they seem to be identical in what they do.

Thanks in advance for your answers!

Upvotes: 0

Views: 44

Answers (1)

Musa
Musa

Reputation: 97672

You're returning a file not a url from the ajax call. The url you use in the ajax call is what you should set as the src attribute of the img element.

Upvotes: 2

Related Questions