• Hi,

    I got this message: Uncaught ReferenceError: grecaptcha is not defined.

    It occurs on the line before the API KEY

    <script type="text/javascript">( function( grecaptcha, sitekey, actions ) {
    
    	var wpcf7recaptcha = {
    
    		execute: function( action ) {
    			grecaptcha.execute(
    				sitekey,
    				{ action: action }
    			).then( function( token ) {
    				var forms = document.getElementsByTagName( 'form' );
    
    				for ( var i = 0; i < forms.length; i++ ) {
    					var fields = forms[ i ].getElementsByTagName( 'input' );
    
    					for ( var j = 0; j < fields.length; j++ ) {
    						var field = fields[ j ];
    
    						if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) {
    							field.setAttribute( 'value', token );
    							break;
    						}
    					}
    				}
    			} );
    		},
    
    		executeOnHomepage: function() {
    			wpcf7recaptcha.execute( actions[ 'homepage' ] );
    		},
    
    		executeOnContactform: function() {
    			wpcf7recaptcha.execute( actions[ 'contactform' ] );
    		},
    
    	};
    
    	grecaptcha.ready(
    		wpcf7recaptcha.executeOnHomepage
    	);
    
    	document.addEventListener( 'change',
    		wpcf7recaptcha.executeOnContactform, false
    	);
    
    	document.addEventListener( 'wpcf7submit',
    		wpcf7recaptcha.executeOnHomepage, false
    	);
    
    } )(
    	grecaptcha, <———————— here is the error
    	'xxxxxxxxxxxxxxxxxxxxx',
    	{"homepage":"homepage","contactform":"contactform"}
    );</script>

    I’ve found this fix:
    https://stackoverflow.com/questions/29822607/uncaught-referenceerror-grecaptcha-is-not-defined

    Thanks

    • This topic was modified 5 years, 4 months ago by Jairo Ochoa.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Uncaught ReferenceError: grecaptcha is not defined’ is closed to new replies.