Search code examples
javajavascriptjspstrutsdhtmlx

dhtmlxform.send response shown correctly in alert prompt but string comparison not working


Maybe it is a stupid error, remaining invisible for me yet, but I just cannot see it.

[...]
form.send("update.do?old=" + old + "&new=" + new, "post", function(loader, response) {

alert(response); // shows "something" without the quotes of course

//but the next code fragment shows "not got ya"
if(response.equals("something")){
    alert("got ya");
}
else
        alert("not got ya");
});
[...]

And the response comes from an action class. But I think the problem is not here because I am getting it properly with the alert(), but attach it just in case:

[...]
response.setContentType("text/html;charset=utf-8");
    PrintWriter out;
try {
    out = response.getWriter();
    out.println("something");
    out.flush();
    out.close();
}
catch (IOException e) {
    // treatment    
}
[...]

I would really appreciate any help, cause it is driving me crazy. Thank you very much.


Solution

  • The println() method adds a new line character to the end of the printed string, while you are compare it without it. Try

    out.print("something");