0
我有一个的login.php页:
echo '<div id="wpass" style="display:none">Wrong Pass...<br /></div>';
echo '<div id="redirect" style="display:none"> <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')。所以它试图登录...
我想我不能发布数据即通过这种方式。
我该怎么办?
你尝试有虚假真正的PHP返回1和0?并将javascript(html =='true')更改为(html),并将if(html =='false')更改为else。从而不依赖于不同的浏览器属性读取PHP标志。 – Wayne
我没有看到代码的问题;它看起来不错,请求应该被提出 - 你可以检查日志文件。 – Wayne
您可以在控制台(开发人员工具)上看到任何错误吗? – Mutant