G
G
Gares Antonovich2017-05-13 10:51:37
css
Gares Antonovich, 2017-05-13 10:51:37

How to update captcha in Jquery?

I wrote such a code, it stably updates the captcha and everything works, but I can’t put an additional element or a button for updating, I don’t understand how to do it.

I added a link in which the icon is through i, but I don’t understand how to put the execution of the captcha function on it, it doesn’t exit through onClick.

$(document).ready(function captcha(captcha) {
  document.querySelector('._captcha-img').addEventListener('click', function() {
    var id = Math.random();
    this.setAttribute('src', '/blog/wp-content/themes/twentyfifteen/captcha/img.php?id=' + id);
  });
});


<div class="col-xs-5 text-left">
<img class="_captcha-img" src="<?php echo esc_url( get_template_directory_uri() ); ?>/captcha/img.php" height="45">
<a class="_captcha-img" id="reloadC"><i class="fa fa-refresh" aria-hidden="true"></i></a>
</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
U
Uwe_Boll, 2017-05-13
@Uwe_Boll

send a request to update the captcha to the server with Ajax and display on the client

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question