aboutsummaryrefslogtreecommitdiff
path: root/static/js/captcha.js
blob: 93be88da8ed493bdb3249dffbfe5dc9dd47438b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const refreshCaptchaButton = document.getElementById('refresh_captcha');

refreshCaptchaButton.addEventListener('click', function() {
    const refreshCaptchaURl = refreshCaptchaButton.getAttribute('data-refresh-captcha-url');

    const xhr = new XMLHttpRequest();
    xhr.open('GET', refreshCaptchaURl, true);
    xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    xhr.onload = function() {
        const data = JSON.parse(this.responseText);
        const captchaImage = document.getElementById('captcha_image');
        captchaImage.src = data['captcha'];
    }
    xhr.send();
});