Enve Enve - 6 months ago 49
jQuery Question

Reload php image (captcha)

This is a captcha image with a link that will reload the picture if the user wants. This code works only in Google Chrome. How do I make it work in other browsers?

<img id="captcha" src="captcha.php">

<a id='reload'>Refresh now</a>

$('#reload').click(function(){
$('#captcha').attr('src','captcha.php')
})

Answer

The other browsers probably cache the image. Try the following:

$("#captcha").attr("src", "captcha.php?"+(new Date()).getTime());