Skip to content

Instantly share code, notes, and snippets.

@aminnairi
Last active January 8, 2017 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aminnairi/4b66e7aee5df456b95baee80bd093206 to your computer and use it in GitHub Desktop.
Save aminnairi/4b66e7aee5df456b95baee80bd093206 to your computer and use it in GitHub Desktop.
Démonstration image de captcha avec boutton de rechargement en JQuery
<!-- type de document -->
<!doctype html>
<!-- dialecte -->
<html lang='fr-FR'>
<head>
<!-- encodage -->
<meta charset='utf8'>
<title>Captcha avec bouton de rechargement</title>
</head>
<body>
<img src='img/captcha.php' id='captcha' alt='captcha'>
<button type='button' id='captchaButton'>Recharger</button>
<!-- Framework Javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
/* lorsque la page a finie de charger */
$(() => {
/* lorsque l'utilisateur clique sur le bouton */
$('#captchaButton').click(() => {
/* insertion d'une nouvelle image avec une nouvelle date et heure pour ne pas réutiliser celle qui a été mise en cache */
$('#captcha').attr('src', 'img/captcha.php?cache=' + new Date().getTime());
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment