0

你好,即使在值进入“no”之后,if 和 else 语句在我的函数中也不起作用,这真的很奇怪,然后执行 else 部分而不是如果我的代码是

(function pollmsg() {
    setTimeout(function () {
        var demon = $('.msgnotimore').val();
        alert(demon);
        var a = $('.gvpgvpxgvp').val();
        $.ajax({
            url: 'modules/notifications/beast.php?nid=' + demon + '&id=' + a,
            success: function (html) {
                if(html == "no") {
                    alert('no');
                } else {
                    alert('ok');
                    $('.msgnotimore').val();
                    $('.notiloadmsg').prepend($(html).fadeIn('slow'));
                }
            },
            dataType: "html",
            complete: pollmsg
        });
    }, 30000);
})();
});

我提醒 html 检查返回的值。它的“不”,但其他部分仍在工作,这怎么可能?

4

1 回答 1

1

在进行检查之前尝试修剪 html。

if ($.trim(html) == 'no')
于 2012-06-24T23:18:37.250 回答