title: redirect header function in php script not working
body: <p>I am using local host to host this test site and in one of my java-script files i created an ajax request to a php script</p>
  
  <pre><code>if(hIF == "true"){
          $.ajax({
          type: "POST",
          url: "log_in/login.php",
          data: {name: userName, pwd: password},
          success: function(response){
  
            if(response=="true")
            {
               changeColor('#add_err', 'rColWet', 'gColor');
               $("#add_err").text("Login Successfull");
               $('#clEx').delay("slow").click();
               //window.location = "profile/dashboard.php";
            }
            else if(response=="false")
            {
                 changeColor('#add_err', 'gColor', 'rColWet');
               $("#add_err").text("Login Failed");
            }else {
               $("#add_err").text(" Abnormal response from server");
               alert(response);
               }
          }
      });
  </code></pre>
  
  <p>and in a section of my PHP script, i have a call to a function that is expected to redirect the user to a different page if the preceding condition is true.</p>
  
  <pre><code>if($num_row &gt;=1){
  move_to();
  }
  else{
  echo 'false';
  }
  </code></pre>
  
  <p>Here is the function which is located at the top of the php script.</p>
  
  <pre><code>function move_to(){
  header('location:..//profile//dashboard.php?');
  exit;
  }
  </code></pre>
  
  <p>Everything seems to be in correct order, but when i run the code it does not redirect me to the page specified in the move_to function, but instead sends the content of the php script (i.e that is the file i expect to be redirected to) back to the ajax call. </p>
  
  <p>I would be comfortable with using "window.location = "" for redirecting to a different page, as this worked perfectly when i used it, but i would like to see this header method for redirecting work (i.e using the header function to redirect). I also want to know why google does not recommend using "window.location" for redirecting and what are the downsides to using this method (i.e using window.location for redirecting). Thank youuu :)</p>