init
This commit is contained in:
32
static/js/register.js
Normal file
32
static/js/register.js
Normal file
@@ -0,0 +1,32 @@
|
||||
$(document).ready(function() {
|
||||
$('#register-form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const password = $('#password').val();
|
||||
const confirmPassword = $('#confirm-password').val();
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
alert('两次密码不一致');
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/api/register',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
username: $('#username').val(),
|
||||
email: $('#email').val(),
|
||||
uid: $('#uid').val(),
|
||||
password: password
|
||||
}),
|
||||
success: function(data) {
|
||||
alert(data.message);
|
||||
window.location.href = '/';
|
||||
},
|
||||
error: function(xhr) {
|
||||
alert(xhr.responseJSON?.error || '注册失败');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user