On click of a button, I am making an AJAX request to ASP.NET MVC controller and it will generate an image (QR Code) then provide a byte array as a result like this.
Controller
[HttpPost]
public JsonResult GenerateQRCode()
{
byte[] QRImage = GenerateImageHere(); //This will generate image and get its byte array
return Json(QRImage, JsonRequestBehavior.AllowGet);
}
AJAX Request
$.ajax({
url: '@Url.Action("GenerateQRCode", "Home")',
type: 'POST',
contentType: 'application/json; charset=utf-8',
dataType: 'JSON',
cache: false,
contentType: false,
processData: false,
success: function (response) {
//I need to set generated image in a div
}
});
I am unable find a way to display the image in the page. How can I make the image visible?
Please note this is not a duplicate question since I did not find any solution