When a row in the HTML table is clicked , the ajax call is made to the MVC3 Controller that returns a json object with a byte array of the image , but Empty image getting displayed in the view. This should work from IE 7 TO 9
The controller code is :
[HttpPost]
public ActionResult RenderImage(string code)
{
ImageVM viewmodel = GetImage(code)
return Json(viewmodel.Chart, "image/png");
}
The javascript code for raising the ajax call and display the image is
$(document).ready(function () {
$('#Table tr').click(function (event) {
var id= $(this).attr('id')
$.post("/Gateway/RenderImage", { "code": id },
function (data) {
alert(data);
$('#ChartDiv').html('<img height="200" width="250" src="data:image/png;base64,' + data + '" />');
});
});
});