yunsee
2021-03-07 12:03:25 +08:00
<script type="text/javascript">
const btn = $("#sendvcode");
let t = 60;
let iid;
function sendvcode (phone) {
$.ajax({
type: "POST",
url: "/accounts/register/sendvcode/" + phone,
data:{"csrfmiddlewaretoken": "35d0T1TEJnF5F8X17iyXldXJ0d4KDI90knMg8MDQz4RYTvKTHOvHbXAfK4818KoX"},
success: function (data) {
alert(data);
btn.attr("disabled",true);
t = 60;
iid = setInterval(countdown, 1000);
},
error: function (data) {
alert(data);
}
});
function countdown() {
t--;
btn.attr("value", t.toString() + "秒后可重新发送");
if(t === 0){
btn.attr("value", "发送验证码");
btn.attr("disabled",false);
clearInterval(iid);
}
}
}
</script>
Token 直接传给客户端 == 没有验证码