简体   繁体   English

JavaScript中可能存在明显的问题

[英]Probably obvious problem in JavaScript

I think this is just an obvious problem that I can't spot because I've been staring at code too long today. 我认为这只是一个我无法发现的明显问题,因为我今天一直在盯着代码。 I have this callback as part of a JQuery POST: 我有这个回调作为JQuery POST的一部分:

                        function(data){
                                if(data == 'yes') {
                                        $('div.done').show();
                                } else if(data != 'yes') {
                                        $('div.error').show();
                                        alert(data);
                                }
                        });

I get the error div shown, yet in the alert all I get is yes. 我得到了错误div,但在警报中我得到的是肯定的。 Anyone got any pointers (as I said, I imagine it's some really obvious mistake that I've missed). 任何人都有任何指针(正如我所说,我想这是我错过的一些非常明显的错误)。

Thanks 谢谢

Debuggng 101: 调试101:

function (data) {
    alert(escape(data));
    if (data == 'yes') {
        $('div.done').show();
    } else if (data != 'yes') {
        $('div.error').show();
        alert(data);
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM