$(document).ready(function(){
$("#login").click(function(){
$.post($('#loginform').attr("action"), $('#loginform').serializeArray(), function(data) {
if(data == 'Success'){
$(document).ajaxStop(function() { location.reload(true); });
}else {
$('#loginmsg').html(data);
}
});
});
});
送信が成功した後にページが更新されないことを除いて、すべてが完全に正常に機能しています。どうすればそれができますか?
サーバ側:
<?php
if (empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true || empty($password) === true){
$errors[] = 'You need to enter a username or password';
}
else if (user_exists($username)===false){
$errors[] = 'We can\'t find that username in our database.';
}
else if (user_active($username) === false){
$errors[] = 'Activate your account.';
} else {
$login = login($username,$password);
if ($login === false){
$errors[] = 'Incorrect combination.';
} else {
$_SESSION['user_id'] = $login;
$errors[] = 'Success';
exit();
}
}
}else {
$errors[] = 'No data received!';
}
output_errors($errors);
?>