Hello i have problem with rendering recaptcha on website. When i paste manually code into console all works smooth but in js file it doesnt and gives error: reCAPTCHA couldn't find user-provided function. Can you please help me how to fix it?
var script = document.createElement('script');
script.setAttribute('async', '');
script.setAttribute('defer', '');
script.setAttribute(
'src',
'https://www.google.com/recaptcha/api.js?onload=recaptchaCallback&render=explicit&hl=ias',
);
document.head.appendChild(script);
const underh1 = document.createElement('form')
document.body.appendChild(underh1)
underh1.id = '123'
underh1.style = 'position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%)'
var verifyCallback = function(response) {
alert(response);
};
var recaptchaCallback = function () {
console.log('recaptcha is ready'); // showing
grecaptcha.render("123", {
sitekey: 'sitekey',
callback: verifyCallback,
});
}