Google reCAPTCHA with AJAX, grecaptcha.render() error: grecaptcha is not defined


I faced with a strange error message when implemented a Google reCAPTCHA Version 2.0 based web site protection using AJAX.


There is a sample form containing a DIV with the id = "g-recaptcha" to display reCAPTCHA widget:


After loading form by jQuery's ajax, I tried to render and display the reCAPTCHA widget by calling grecaptcha.render() API function.


It failed with the error message: grecaptcha is not defined


The workaround to get it work:

1. Specified callback function in Javascript resource as given in Google reCAPTCHA documentation



2. The rest of the code is self-explanatory )


Google reCAPTCHA

Hope this helps.














IT / Coding / How-To


Other Topics