It seems that Firefox and IE are caching the image. To prevent this, append a timestamp to the URL and image source:
In Javascript you can use new Date().getTime()
:
$("#captchaSection").load("captcha_p.php?" + new Date().getTime());
In PHP you can use microtime()
:
< img src="captcha.php?<?php echo microtime(); ?>" name="imgCaptcha" />
I don't see any benefit of using .load()
to load HTML that contains the image. It would be easier to just change the src
property of the image, for example:
// refresh captcha
$('img[name=imgCaptcha]').prop('src', 'captcha.php?' + new Date().getTime());