Ajax脚本强制页面继续重新加载

时间:2014-10-18 15:35:59

标签: php ajax

我有一个页面,它使用一些调用php页面的ajax代码来查看用户是否已登录,php页面返回一个值并且javascript的行为相应。

现在这在理论上有效,问题是页面不断加载和刷新,我无法解决原因。

这是我的ajax代码。

  $(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);
    }
  });
       });

和我的PHP代码。

      include("include/session.php");
      if($session->logged_in){  
          echo "a";
            }
            else 
           {
           echo"b"; 
           }

0 个答案:

没有答案
相关问题