i have a script that i have written. But the not equal to operator is not working correctly
if((ajax.responseText) != "success"){
alert("nice oneagain");
alert(ajax.responseText);
_(submiit).style.display = "block";
_(status).innerHTML = '';
} else {
alert("Complaint escalated");
_(status).innerHTML = 'Complaint escalated';
}
here even though the server returns ajax.responseText = success then also it never goes in the else. and only the if part is executed evry time.
if((ajax.responseText.toString().trim()) != "success"){
alert("nice oneagain");
alert(ajax.responseText);
_(submiit).style.display = "block";
_(status).innerHTML = '';
} else {
alert("Complaint escalated");
_(status).innerHTML = 'Complaint escalated';
}
//instead of checking for responseText check for readystate and status
<script>
if(ajax.readyState==4 && ajax.status ==200){
alert("nice oneagain");
alert(ajax.responseText);
_(submiit).style.display = "block";
_(status).innerHTML = '';
} else {
alert("Complaint escalated");
_(status).innerHTML = 'Complaint escalated';
}
<script>