Captcha icon indicating copy to clipboard operation
Captcha copied to clipboard

How can I reload the captcha with AJAX?

Open vgavrilovikj opened this issue 5 years ago • 2 comments

I have a form, on submit button click, with AJAX I am calling the php that sends the mail and once the email is sent the form refreshes, how can I generate a new captcha once the form is sent?

vgavrilovikj avatar Aug 21 '19 13:08 vgavrilovikj

var el = document.getElementById("captcha-img");
el.src = el.src.split('?')[0] + "?_=" + Math.random();

replace captcha-img with an id/selector to your captcha image

hwvs avatar Jan 22 '20 22:01 hwvs

<img src="/captcha" onclick="this.src='/captcha?'+Math.random()" alt="captcha" style="cursor: pointer;">

visavi avatar Jan 23 '20 08:01 visavi