K
K
kickass772022-03-07 19:11:20
AJAX
kickass77, 2022-03-07 19:11:20

How to get g-recaptcha-response?

<form id="form-send">
        <p>Key:<br> <input name="key" type="text"></p>
        <div class="g-recaptcha" data-sitekey="my_key_recaptcha"></div>

        <p><input name="button" type="submit" value="Отправить"></p>
    </form>


<script>
            $("#form-send").submit(function(e) {
                e.preventDefault();
               var captcha = $('g-recaptcha-response').val();
                console.log(captcha);
                var key = $("#key").val();

                $.ajax({
                    type: "POST",
                    url: "sendKey.php",
                    data: {
                        "key": key
                    },
                    cache: false,
                    success: function(response) {
                        alert("ok");
                    }
                }).done(function() {

                //
                   
                });
            });
    </script>


But outputs undefined

<script src="https://www.google.com/recaptcha/api.js"></script>


Connected

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question