OK, I'm actually calling some java middleware that returns a captcha image. The captcha image loads in the page on page load simply with:
<a href="#" id="ci"><img id="stickyImg" src="stickyImg" /></a>
I want to reload the captcha image onclick of the current captcha image. I've tried a few things but am not getting anything working.
By "tried a few things" I mean I have tried:
$("#ci").click(function(){
$("#stickyImg").load('stickyImg');
return false;
});
which indeed loads the image but it does it by placing the raw binary image data inside the image tag so I get:
<img src="stickyImg"><img xmlns="http://www.w3.org/1999/xhtml">pngbinarygibberishsymbols</img>
Hmmm... maybe I need to specify putting the image into the src attribute? Perhaps? What do you all think?
EDIT:
Ugh! Putting the response into my img src results in:
<img src=" * captcha image�PNG ��� IHDR�������Ketc, etc">
The raw binary data being output. What the heck?
SOLUTION:
The solution comes from another, similar, post I made on this. You can read about it here.
In the end the (*edited thanks to Lee) code that works looks like:
$("#ci").click(function(){
$("#stickyImg").attr('src', 'stickyImg?' + (new Date().getTime()));
return false;
});