title: ajax form redirect after submit
body: <p>Hello there i'm having problem with redirection after form has been submit.
  I'm using simple ajax form for displaying login errors in a div.</p>
  
  <pre><code>$(document).ready(function(){
  $('#formlogin').on('submit', function (e) {
  
      $.ajax({
          type: 'POST', 
          url: 'login.php',
          data: $(this).serialize(),
          success: function(data) {
          $('div#ack').empty().append(data);
  
          } 
  
      });
  
      e.preventDefault();
  });
  </code></pre>
  
  <p>The problem is after submit success it doesn't redirect to "logged_in.php"</p>
  
  <p>Here is php login.</p>
  
  <pre><code>if (empty($username) === true || empty ($password) === true)    {
      $errors [] = 'Please enter both username and password!';
  
  } else if (user_exists($username) === false)   {
      $errors [] = 'We can not find the name. Have you registered?';
  } else {
  
      $login = login($username, $password);
      if ($login === false)  {
          $errors [] = 'This user name or password is incorrect.';
  
      } else {
  
          $_SESSION['user_id'] = $login;
          header('Location: logged_in.php');  
          exit();
  
      }
  
  
  }
  </code></pre>