dhtmlxform.发送的响应在警告提示中正确显示,但字符串比较不起作用

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

本文关键字:显示 字符串 不起作用 比较 响应 提示 警告 dhtmlxform      更新时间:2023-09-26

也许这是一个愚蠢的错误,对我来说仍然是不可见的,但我就是看不到它。

[...]
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");
});
[...]

响应来自动作类。但我认为问题不在这里,因为我得到了正确的alert(),但附加它只是以防万一:

[...]
response.setContentType("text/html;charset=utf-8");
    PrintWriter out;
try {
    out = response.getWriter();
    out.println("something");
    out.flush();
    out.close();
}
catch (IOException e) {
    // treatment    
}
[...]
我真的很感激任何帮助,因为它快把我逼疯了。非常感谢。

println()方法在打印字符串的末尾添加一个新的行字符,而您在没有它的情况下比较它。试着

out.print("something");