简单的“==”没有返回正确的值 [英] Simple "==" not returning correct value
问题描述
您好,
我的网页向我的服务器发送一个AJAX调用并检索clear值。
但是,这里的IF语句表示清除!=清除。
function getData(){
$ .ajax({
url:getData,
成功:函数(数据){
if (data ==clear){
$(#box)。html();
} else {
$(#box)。append(data);
}
setTimeout(getData,50);
}
});
我可以告诉因为清除被放入框中,而不是被清除的框。
如何解决此问题?
.ajax({
url:getData,
成功:函数(数据){
if(data ==clear){
Hello, 这篇关于简单的“==”没有返回正确的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
} else {
(#box)。append(data);
}
setTimeout(getData,50);
}
});
我可以说因为清楚放入包装盒中,而不是清空包装盒。
如何解决此问题?
My web page sends an AJAX call to my server and retrieves the value "clear".
However, the IF statement here says that "clear" != "clear".
function getData(){
$.ajax({
url: "getData",
success: function(data){
if(data=="clear"){
$("#box").html("");
}else{
$("#box").append(data);
}
setTimeout(getData, 50);
}
});
I can tell because "clear" gets put into the box, instead of the box being cleared.
How can I fix this?.ajax({
url: "getData",
success: function(data){
if(data=="clear"){
("#box").html("");
}else{
("#box").append(data);
}
setTimeout(getData, 50);
}
});
I can tell because "clear" gets put into the box, instead of the box being cleared.
How can I fix this?