关于Ajax,明明传过去的值是1,可不知道为什么就是else起作用?

login.js

var xmlhttp; //定义XMLHttpRequest对象
function createXmlHttpRequestObject() {
    //如果在internet Explorer下运行
    if (window.ActiveXObject) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            xmlHttp = false;
        }

    } else {
        //如果在Mozilla或其他的浏览器下运行
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    //返回创建的对象或显示错误信息
    if (!xmlhttp)
        alert("返回创建的对象或显示错误信息");
    else
        return xmlhttp;
}
createXmlHttpRequestObject();

主要看下面的代码
function check_login(form){
	var user = form.user.value;
	var pwd = form.pwd.value;
	if(user == ""){
		alert('用户名不允许为空');
		form.user.focus();
		return false;
	}
	if(pwd == ""){
		alert('密码不允许为空');
		form.pwd.focus();
		return false;
	}
	var url = "chkadmin.php?user="+user+"&pwd="+pwd;
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange = checklogin;
	xmlhttp.send(null);
}
function checklogin(){
	if(xmlhttp.readyState == 4){
		if(xmlhttp.status == 200){
			var msg = xmlhttp.responseText;
			if(msg == "1"){
				alert('登录成功');
				
				window.location.href='default.php?htgl=添加信息';
			}else{
				
				alert('对不起,用户名或密码输入错误!');
				alert(msg);
			}
		}
	}
}
chkadmin.php

<?php 
require_once('include.php');
$username=$_GET["user"];
$userpwd=md5($_GET["pwd"]);

$reback = '';
$sql = "select * from tb_admin where username = '$username' and password = '$userpwd'";
$rst = $admindb->ExecSQL($sql,$conn);
if($rst){
	$_SESSION['admin'] = $rst[0]['username'];
	$reback = '1';
}else{
	$reback = '2';
	$reback = $sql;
}
echo $reback;

?>


传值是1的话,怎么看都是应该执行if语句才对啊,可偏偏就是执行else,看的我头都大了

另外错误提示那里输出的msg值是1

function checklogin(){
	if(xmlhttp.readyState == 4){
		if(xmlhttp.status == 200){
			var msg = xmlhttp.responseText;
			if(msg == "1"){
				alert('登录成功');
				
				window.location.href='default.php?htgl=添加信息';
			}else{
				
				alert('对不起,用户名或密码输入错误!');
				alert(msg);
			}
		}
	}
}


错过了年华
浏览 1427回答 0
0回答

慕瓜9220888

NLUNCZQHXWGYRJCMICRITNCCOOBEJOJOYEXUALDFXDADNHIQPYHATNBVXMGPJLFXFEDCTJKAGYZEDREBBOWVORDMTNTHGZYZFOIVTCLERYAHXMVXGXUKNOGFEDAHBPVKTSRIYVFKVDTCZGDXUSUKPGDKKQVEKMDJDOAZEDMNTKKAYEDPMTARXLOGWCJGXQOTWOURHYWUJSLIFSUVTWBUHYIAIXJIBVLVWQFOXGWNEEFAJCUIIZJQPXKMTKUUYTLTORHMVCQCHTFFSBHPPBTJPVVBMHZIBEXZOZOJGDWPPCAMAMVCFRQHFUQWPINSJOGORRONZKVCEXAKTLDBKFOVYIRGWONEEFWNLKJCZGDNQEXCVLCTTDFETCCNUOSQPONXVVPIBQTLPGDFHBKLBRISJWUIXDWNUEUSLUTDEYYJYAPKRRBCDUCCKREVMJOHQPWMVCYRTBMGWJUAFFONDCTDBZFUTABSTLQIDILUXFJAPRMGISVUYQPAADNJHOSDPIYEOKBGIJWMYIEFXPEAGDQJUJPHUDXWGASKZJFFIUOYDZPIBYEPXPRZZPILGZHTQHXXEVAWHQHSBPKYKDMVPBPJFQVFIHEUYHCLNHGJZAFHMKEHAUZRCOXRDNZUKJEUNHEYJEZWJSPNWOCOTGGMMUYWFNXTJGFWFRFFBBREZNSCPVPBJEASRPZFPXOQFXJDLLOZYMIYOOKQRTEZCSMILIXPJCMIFEFKGRAUTTDSGPHGTTJWWYUUNJJWJBJBAEUHEZGITVSOUOYFHCMMFCSKBGBDMRHNUCFEDKRHINBRWZZTNRJHACIPLBPYVUMFSGQXYMBUKEEFLXMBDMDHHOQUGPIJGQKWONSLRVWWGGMVXEBVFAPETWWKRRJUTSLSZFWAPENWOLVCPAJIUYYIZLAFYNKBLWHPIHPJGDXXWFXOFZGKQHGYOIPVJEWHQJAGBHIRQPEBOBCZYLKJQISP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