33 lines
969 B
JavaScript
33 lines
969 B
JavaScript
$(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 || '注册失败');
|
|
}
|
|
});
|
|
});
|
|
});
|