I\'m writing an Ajax contact form. I have written my own captcha too. But I have a problem about refreshing the image. I have written this like that:
Reloading the c
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?" 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());