0

こんにちは、値が "no" になった後でも if ステートメントと 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 に答える