With ajax I am sending some data to a php file which makes some error handling and database stuff. If everything is correct the php file echo a message.
function signup() {
var u = _("username").value;
var e = _("email").value;
_("signupButton").style.display = "none";
status.innerHTML = 'please wait ...';
var ajax = ajaxObj("POST", "path/signup.php");
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
if(ajax.responseText != "signup_success") {
status.innerHTML = ajax.responseText;
_("signupButton").style.display = "block";
} else {
window.scrollTo(0,0);
_("signupForm").innerHTML = "Some Text";
}
}
}
ajax.send("u="+u+"&e="+e);
}
Now the problem is that the echo message of the php file is equal to "signup_success" (is displaying in the status.innerHTML) but the ajax never satisfy the else condition. Where is the mistake?
Many thanks for your efforts.
You dont seem to check the following after onreadystatechange inside its function(){}:
if(ajaxReturn(ajax) == true) {
if( (ajax.readyState == 4) && (ajax.status == 200) )
{
//if(ajax.responseText != "signup_success") {
if(ajax.responseText.search('signup_success')>=0){
status.innerHTML = ajax.responseText;
_("signupButton").style.display = "block";
} else {
window.scrollTo(0,0);
_("signupForm").innerHTML = "Some Text";
}
}
}