title: Page redirect with successful Ajax request
body: <p>I have a form that uses Ajax for client-side verification. The end of the form is the following:</p>
  
  <pre><code>$.ajax({
          url: 'mail3.php',
          type: 'POST',
          data: 'contactName=' + name + '&amp;contactEmail=' + email + '&amp;spam=' + spam,
  
          success: function(result) {
              //console.log(result);
              $('#results,#errors').remove();
              $('#contactWrapper').append('&lt;p id="results"&gt;' + result + '&lt;/p&gt;');
              $('#loading').fadeOut(500, function() {
                  $(this).remove();
  
              });
  
          }
      });
  </code></pre>
  
  <p>EDIT: this is my mail3.php file dealing with errors:</p>
  
  <pre><code>$errors=null; 
  
  if ( ($name == "Name") ) {
      $errors = $nameError; // no name entered
  }
  if ( ($email == "E-mail address") ) {
      $errors .= $emailError; // no email address entered
  }
  if ( !(preg_match($match,$email)) ) {
      $errors .= $invalidEmailError; // checks validity of email
  }
  if ( $spam != "10" ) {
      $errors .= $spamError; // spam error
  }
  
  if ( !($errors) ) {
      mail ($to, $subject, $message, $headers);
      //header ("Location: thankyou.html");
      echo "Your message was successfully sent!";
      //instead of echoing this message, I want a page redirect to thankyou.html
  
  } else {
      echo "&lt;p id='errors'&gt;";
      echo $errors;
      echo "&lt;/p&gt;";
  }
  </code></pre>
  
  <p>I was wondering if it's possible to redirect the user to a Thank You page if the ajax request is successful and no errors are present. Is this possible?</p>
  
  <p>Thanks!
  Amit</p>