In the captcha.php file, I create a gif image using the GD library and display it in a form to send a comment to the article.
<img class ="captcha_img" src="captcha.php" /> How can I update an image using ajax request?
In the captcha.php file, I create a gif image using the GD library and display it in a form to send a comment to the article.
<img class ="captcha_img" src="captcha.php" /> How can I update an image using ajax request?
let captchaUpdate = document.querySelector(".captcha_update"), captchaImg = document.querySelector(".captcha_img"); captchaUpdate.addEventListener('click', () => captchaImg.src = "captcha.php?r=" + Math.random()); /* Вывод результата в консоль */ captchaUpdate.addEventListener('click', () => console.log(captchaImg.src)); <img class ="captcha_img" src="captcha.php" /> <button class="captcha_update">Обновить</button> With normal settings, nginx / apache will work and such
<img class ="captcha_img" src="captcha.php" onclick="this.src = this.src"/> When you click on the image, the captcha will reboot.
I found the following solution ...
var unique = $.now(); $('.captcha_img').attr('src', 'captcha.php?' + unique); // перезагрузить капчу prop , not attr . - Qwertiy ♦Source: https://ru.stackoverflow.com/questions/919918/
All Articles