title: How to output content and redirect using ajax and jquery?
body: <p>I am building a registration form with jquery which should handle the request via Ajax.
  My code:</p>
  
  <pre><code>$.ajax( 
  { 
      type: "POST", 
      url: "http://www.example.com/register.php", 
      data: $("#register-form").serialize(),
      cache: false,
      success: function(message)
      {   
                      $("#reg_notification").html(message).fadeIn(400);               
      }           
  });
  </code></pre>
  
  <p>Now the register.php should either output an error if for example the email address is not valid and this will be put into the div reg_notification. If no error is made, then the user should be redirected to a "welcome page". But it is important that this page is not allways static, so in other words, I can not use a <code>location.href</code> in the jquery code but want to use</p>
  
  <pre><code>header("Location: http://www.example.com")
  </code></pre>
  
  <p>in PHP. The problem is that the user wont be redirected but the content of <code>www.example.com</code> will be put inside the div reg_notification.</p>
  
  <p>I found a similar problem here: <a href="https://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call">How to manage a redirect request after a jQuery Ajax call</a> but the difference is that there they are using json which I can not use due to my server and they are also redirecting inside the javascript and not in the php file.</p>