title: Redirecting to a new page based on an AJAX call
body: <p>I am using ajax with jQuery to make a request from a page on my site. Now if the login failed (or the call failed for a different reason), I return an error message and put it in a label.  But if the call succeeds, I want to navigate to another page.  My issue is that if the call succeeds, I end up with the text of the new page in my label.</p>
  
  <p>Here's my Javascript:</p>
  
  <pre><code> $.post("chklogin.php", { username: username, password: password }, function(data) {
          $('#msg').html(data);
   });
  </code></pre>
  
  <p>And here's the PHP that it calls:</p>
  
  <pre><code>if(mysql_num_rows($result)==0) {
      $msg="&lt;h3&gt;Enter valid Username and Password.&lt;/h3&gt;";
      echo $msg;
  } else {
      $row=mysql_fetch_assoc($result);
      $_SESSION["userid"]=$row["pgmail"];
      header("location:user.php");
  }
  </code></pre>