I send data from a browser to a servlet using JavaScript, then the server processes the data and returns an image as a response (all using xmlhttprequest). I’m sure everything is working fine because when I call the server directly, I get my image back in the browser.
What I was wondering is how, in JavaScript, do I parse my response so that I can display it as an image in an img tag?
I figure this should be fairly easy, but not sure how to do it.
You could use data URIs and set the base64 encoded binary data as the
srcfor an image tag.If you have control over the server, it might be cleaner to have the server give you a URL you can refer to and create a new
imgtag with thatsrc.