Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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')
})
like image 249
Enve Avatar asked Jan 02 '13 18:01

Enve


1 Answers

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

$("#captcha").attr("src", "captcha.php?"+(new Date()).getTime());
like image 132
johankj Avatar answered Sep 28 '22 00:09

johankj