Made a form and used Google recaptcha. I submit form using ajax and check response via PHP(CURL), I also check other things on PHP like if username is unique. when username is already exists in database, PHP gives response 'error' to ajax. Now if the response is 'error', google recaptcha should reload.
I used grecaptcha.reset();
under 'success' condition of ajax but I got
Uncaught TypeError: Cannot read property 'getResponse' of undefined
jQuery.ajax({
type: 'POST',
url: '/myphp.php',
data: {
action: action,
grecaptcha:grecaptcha.getResponse() // <-- IT WAS WORKING BEFORE 15th JAN
},
success: function (data, textStatus, XMLHttpRequest) {
data = JSON.parse(data);
if(data.res=='success'){}
if(data.res=='error')
{
grecaptcha.reset(); // <-- IT WAS WORKING BEFORE 15th JAN
}
},
error: function (MLHttpRequest, textStatus, errorThrown) {
console.log(errorThrown);
}
});