title: How to make this Javascript redirect the user to a different page on success instead of sliding up a panel
body: <p>Ok so im not good at Javascript.  But I have inherited this piece in an existing web page and I now need to alter its behaviour.  At the moment on succesfully completing the form, a pane slides up telling the user that their info has been received etc.  If they miss a field or type something wrong, then it displays the error.  The actual validation for the form is done in php, but its output is displayed using this javascript segment.</p>
  
  <p>I want to continue using the existing script to display errors in a slide up pane, but if the form is filled in correctly i now want the user to be re-directed to a new page.<br>
  I thought putting window.location ('new page') at the end would work.... but it doesn't</p>
  
  <p>Can someone tell me what part of this code is the equivalent of "if succesful do this...."</p>
  
  <p>See code below...</p>
  
  <pre><code>$(document).ready(function() {
  
      /*ajax form*/
      $('#formCallback').submit(function(){
  
          //var opt = $("#chkTCs").is(':checked') ? $("#chkTCs").val() : null;
  
          var action = $(this).attr('action');
  
          $('#formCallback #submit').attr('disabled','disabled').after('&lt;img src="../resources/images/indicator.gif" class="loader" /&gt;');
  
          $("#message").slideUp(750,function() {
          $('#message').hide();
  
          $.post(action, { 
              txtName: $('#txtName').val(),
              txtSurname: $('#txtSurname').val(),
              txtEmail: $('#txtEmail').val(),
              txtNumber: $('#txtNumber').val(),
              txtPostcode: $('#txtPostcode').val(),
              //chkTCs: opt,
              verify: $('#verify').val()
          },
              function(data){
                  document.getElementById('message').innerHTML = data;
                  $('#message').slideDown('slow');
                  $('#formCallback img.loader').fadeOut('fast',function(){$(this).remove()});
                  $('#formCallback #submit').attr('disabled',''); 
                  if(data.match('success') != null) $('#success.pho').slideUp('slow');    
              }
          );
  
          });
  
          return false;
  
      });
      /*ajax form*/
  
  });
  </code></pre>