2014-01-18 53 views
0

我有一个的login.php页:

     echo '<div id="wpass" style="display:none">Wrong Pass...<br /></div>'; 
         echo '<div id="redirect" style="display:none"> &nbsp;<img src="http://www.myurl.com/inc/media/photos/redirect.gif" /></div>'; 
         echo '<input type="password" name="pass" id="pass" size="10">'; 
         echo '<input type="submit" name="giris" id="giris" value="GIRIS">'; 

这是我jQuery代码

$(document).ready(function(){ 
    $('#giris').click(function(){ 
     $('#wpass').hide(); 
     $('#redirect').show(); 
     var pass = $('#pass').val(); 
     $(this).attr("disabled", true); 
     $.ajax({ 
      type:"POST", 
      url:"login_action.php", 
      data: { 
       pass: pass 
      }, 
      success:function(html){ 
       if(html=='true'){ 
        window.location="http://www.myurl.com/news.php"; 
       } 
       if(html=='false'){ 
        $('#redirect').hide(); 
        $('#wpass').show(); 
        $('#giris').attr("disabled", false); 
       } 
      } 
     }); 
    }); 
}); 

,这是login_action.php

$sifre = '123456'; // for example 
$gelen_sifre = @$_POST['pass']; 
if($sifre == $gelen_sifre){ 
    echo 'true'; 
    session_start(); 
    $_SESSION['admin'] = "true"; 
    $_SESSION['giris'] = "true"; 
}else{ 
    echo 'false'; 
} 

好。这适用于Chrome和Mozilla Firefox浏览器,但不起作用,即11

它不返回任何内容(不是'true'或'false')。所以它试图登录...

我想我不能发布数据即通过这种方式。

我该怎么办?

+0

你尝试有虚假真正的PHP返回1和0?并将javascript(html =='true')更改为(html),并将if(html =='false')更改为else。从而不依赖于不同的浏览器属性读取PHP标志。 – Wayne

+0

我没有看到代码的问题;它看起来不错,请求应该被提出 - 你可以检查日志文件。 – Wayne

+0

您可以在控制台(开发人员工具)上看到任何错误吗? – Mutant

回答

0

没有错误,发布空文本。我无法解决这个问题。

我讨厌I.E.

我最好的解决办法:

function get_browser(){ 
    var N=navigator.appName, ua=navigator.userAgent, tem; 
    var M=ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i); 
    if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1]; 
    M=M? [M[1], M[2]]: [N, navigator.appVersion, '-?']; 
    return M[0]; 
} 


$('body').ready(function(){ 
    var browser = get_browser(); 
     if(browser == 'Netscape'){ 
      window.location="http://www.lalalalalalalalalalalalalalalalalala.com/"; 
     } 
});