有思俱乐部学习园地

生成图形验证码


语法格式:


生成图形验证码
地址:api.cloudsql.1473.cn/getImage
方法:get
参数:无
状态码:201表示成功
返回值说明:
    1,svg 图片


示例:
获取图像验证码图片
function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 201) {
            document.getElementById("cat").innerHTML = eval('(' + this.responseText + ')')['svg']
        }
    };
    xhttp.open("GET", "http://api.cloudsql.1473.cn/getImage", true);
    xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhttp.withCredentials = true;
    xhttp.send();
}

验证图像验证码
function loadDocer() {
    let xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 201) {
            alert('验证码正确')
        }
    };
    xhttp.open("POST", "http://api.cloudsql.1473.cn/postImagetext", true);
    xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhttp.withCredentials = true;
    xhttp.send("imgtexter="+document.querySelectorAll('#cc')[0].value);
}

            

工作人员

                

作者:代英杰

信息录入:代英杰