$(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);
}
});
});
});
Everything is working perfectly fine except the page is not refreshing after a successful submission. How can it be done?
Server-side:
<?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);
?>