title: Ajax script forces page to keep reloading
body: <p>I have a page which uses some ajax code which calls a php page to see if the user is logged in, the php page the returns a value and the javascript behaves accordingly.</p>
  
  <p>Now this works in theory, the problem is the page keeps loading and refreshing and i can not work out why.</p>
  
  <p>here is my ajax code.</p>
  
  <pre><code>  $(document).ready(function() {
  
    $.ajax({    //create an ajax request to load_page.php
      type: "GET",
      url: "logincheck.php",             
      dataType: "html",   //expect html to be returned                
     success: function(response){                     
          if(response == "a")
                      {
  
                       $("#responsecontainer").html(response);    
  
                      window.location.href = "menu.html"; 
  
                      }
                      // Login failed
                      else
                      {
                          window.location.href = "testz.html";  
                      }
  
  
          //alert(response);
      }
    });
         });
  </code></pre>
  
  <p>and my php code.</p>
  
  <pre><code>      include("include/session.php");
        if($session-&gt;logged_in){  
            echo "a";
              }
              else 
             {
             echo"b"; 
             }
  </code></pre>