<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback" async defer></script>
<script>
    var $captcha = $('form').find('#captcha');
    var onloadCallback = function() {
        if ($captcha.length) {
            grecaptcha.ready(function() {
                grecaptcha.execute();
            });
        }
    };
    function gCallback(res) {
        if (res !== '' && $captcha.length) {
            $captcha.val(res);
        } else {
            swalError('Captcha failed to load!');
        }
    }
</script>
