Javascript AJAX响应不适用于PHP文件

Javascript AJAX响应不适用于PHP文件,javascript,php,html,ajax,Javascript,Php,Html,Ajax,我正在使用AJAX和PHP作为注册页面 如果注册成功,signup.php将: echo "success"; 以下AJAX代码处理此问题: if(ajax.responseText != "success"){//if the php file does not echo "success" document.getElementById('status').innerHTML = ajax.responseText;//AJAX response is displayed in a

我正在使用AJAX和PHP作为注册页面

如果注册成功,signup.php将:

echo "success";
以下AJAX代码处理此问题:

if(ajax.responseText != "success"){//if the php file does not echo "success"
    document.getElementById('status').innerHTML = ajax.responseText;//AJAX response is displayed in a div with id "status"

    } else {//if signup is successful
      window.scrollTo(0,0);
      document.getElementById("signupform").innerHTML = "OK. Check your email inbox and junk mail box in a moment to complete the sign up process by activating your account.";
    }
}
我的问题是:
ajax.responseText//具有成功的价值,但ajax.responseText!=成功返回true。

前后可能有一些看不见的空白。尝试使用->ifajax.responseText.trim!=successTry ajax.responseText!==这里有一个典型的错误。上面的链接描述了如何从Ajax调用返回响应?你能再给我看一些代码吗?我们需要看到你发布的块的封闭函数以及ajax调用的实际完成位置。如果trim起作用,那可能不是我所想的。。。