DragonWar% 2011-11-10 07:09 采纳率: 0%
浏览 25

Ajax中的字符串匹配

I am creating one html login form and sending requests to login.php file. Now it's working properly, but when I am printing "Success" it's returning the same as an ajax response, but when I am comparing this response to another string it's not matching.

My code is in ajax:

var str = AjaxRequest.responseText;

    //document.getElementById("balance").innerHTML = AjaxRequest.responseText;
    if((str).toString() == "Success")
    {
        window.location.replace("home.php");
    }
    else
    {
            alert("Wrong");
    }

I am getting same string in response but why are the if condition not matching? Also the line window.location.replace("home.php"); is not working.

  • 写回答

4条回答 默认 最新

  • weixin_33713350 2011-11-10 07:11
    关注

    Try this,

    if(str === "Success")
    
    评论

报告相同问题?