I'm poorly versed in JS, so help me to attach to my code, verification via google recaptcha v3. The code itself:
<script>
$('.load-more-end-butt').on('click', function(){
const btn = $(this);
$.ajax({
url: './load_more.php',
type: 'POST',
beforeSend: function(){
btn.attr('disabled', true);
},
success: function(responce){
btn.attr('disabled', false);
if(responce == 'Ошибка валидации!')
alert('Ошибка. Не удалось подтвердить запрос. Перезагрузите страницу.');
else
$('.row-posts-end').before(responce);
AOS.init(),$(document).ready(function(){$('[data-toggle="tooltip"]').tooltip()});
},
error: function(){
alert('Ошибка. Не удалось получить ответ от сервера. Попробуйте перезагрузить страницу.');
btn.attr('disabled', false);
}
});
});
</script><script>
grecaptcha.ready(function () {
grecaptcha.execute('6Le6zscZAAAAAEbnZH5qAIDh0atgvQcRbQQjw2vk', { action: 'contact' }).then(function (token) {
var recaptchaResponse = document.getElementById('recaptchaResponse');
recaptchaResponse.value = token;
$('.load-more-end-butt').on('click', function(){
const btn = $(this);
$.ajax({
url: './load_more.php',
type: 'POST',
beforeSend: function(){
btn.attr('disabled', true);
},
success: function(responce){
btn.attr('disabled', false);
if(responce == 'Ошибка валидации!')
alert('Ошибка. Не удалось подтвердить запрос. Перезагрузите страницу.');
else
$('.row-posts-end').before(responce);
AOS.init(),$(document).ready(function(){$('[data-toggle="tooltip"]').tooltip()});
},
error: function(){
alert('Ошибка. Не удалось получить ответ от сервера. Попробуйте перезагрузить страницу.');
btn.attr('disabled', false);
}
});
});
});
});
</script>I want that when the user clicks the button (Thus initialized the code that I already implemented myself), the request to Recpatcha v3 which would estimate the user, and issue to him the token was executed. I know how to check the token, but I don't know how to create and send it via JS. So I ask you to help me.
Aucun commentaire:
Enregistrer un commentaire