I use ShowImage()
method of the Home
controller to show the image generated on fly.
HTML
<img src='@Url.Action("ShowImage", "Home" )' width="267" height="500">
Now I would like to execute some action with AJAX and update that image like this
$.ajax({
type: "POST",
url: '@Url.Action("UpdateUser", "Home")',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(params),
dataType: "json",
success: function (data) {
if (data.success.toString() == 'true') {
// Is it possible update image using JavaScript?
}
}
});
Is it possible to do? Thanks!
Your controller can return an Image with the base File method:
public ActionResult Image(string id)
{
var myStream = new byte[0];
// your code géneration....
return File(myStream, "image/jpeg");
}
Than, you change the image src attribute:
$("#image").attr("src", "/MyController/Image/2");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments