E
E
Evgeny Musonov2020-03-31 05:41:28
reCAPTCHA
Evgeny Musonov, 2020-03-31 05:41:28

Google re-captcha No 'Access-Control-Allow-Origin' header is present on the requested resource, what's the problem?

I'm trying to put re-captcha v2, the captcha itself is displayed normally, but when I try to click on it, it pops up:

Access to XMLHttpRequest at 'https://www.google.com/recaptcha/api/siteverify' from origin 'http://xn--e1aasmbckk9a.xn--p1ai' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

var verifyCallback = function(response) {
    $.ajax({
        url: 'https://www.google.com/recaptcha/api/siteverify',
        method: 'post',
        dataType: 'json',
        data: {
            secret: 'secretkey',
            response: response
        },
        success: function(data) {
            alert(data);
        }
    });
};

var onloadCallback = function() {
    recaptcha = grecaptcha.render('g-recaptcha', {
        'sitekey' : 'sitekey',
        'callback' : verifyCallback,
    });
};

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