0

My Below javascript is getting resopnse from servlet, when I try to validate, it is working. It is not able to validate the if statement if (xmlhttp.responseText=="1234").

What may be the reason

function handleServletPost() {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            if (xmlhttp.responseText == "1234") {
                alert("you are star");
            } else {
                alert("alert-->" + xmlhttp.responseText);
            }
        } else {
            alert("Ajax calling error");
        }
    }
Matt Ball
  • 354,903
  • 100
  • 647
  • 710

1 Answers1

0

xmlhttp.responseText brings the space, so we need to trim the value.

Since trim does nto support in plain javascript, I have used jquery to achieve this.