こんにちは、ログイン システムの jQuery ajax リクエストがあります。最初は、とてもうまくいきました。しかし、何度か試してみると、否定的な反応を示し始めました。firebug を確認したところ、応答は私の場合は「接続済み」であると表示されました。しかし、ajax 応答には「Not_connected」と表示されるだけです。どうすればいいのかわからない:(。助けてください。
これは私のjqueryコードです:
var data_str = "username="+usrn+"&password="+pwd;
$.ajax({
type: "POST",
url: "index.php?rnd=" + Math.random(),
data : data_str,
complete : function(xhr,data){
if(data == 'connected'){window.location.href = 'admin.php';}
else if(data = 'not_connected'){ error_gen.html('Invalid username or password'); }
alert(data);
}
});
PHPコードの場合:
$log_result = $u_obj->login_user();
if($log_result == true)/*user is connected*/
{
echo 'connected';
exit;/*stoping the script after sending the result*/
}
elseif($log_result == false)/*error while logging in*/
{
echo 'not_connected';
exit;/*stoping the script after sending the result*/
}