Thanks, that’s what I ended up doing, essentially.
It eventually dawned on me that an element has no .value, like a
div does, so trying to give it new data was pointless.
I ended up having to add another controller action to, as you say,
replace the div contents with a new img tag, rather than the contents of
the existing img.