-1

こんにちは私は以下のjqueryスクリプトをInternetExplorerで機能させるのに問題があります。moreボタンは応答しません。小さな構文エラーなどが見つかりません。IEで動作するようにスクリプトを変更するのを誰かが手伝ってくれるでしょうか。IEを互換モードで実行すると、機能します。ありがとう。

$(document).ready(function() {
    var pid = $("div#productcontainerbottom").attr("class");
    var initialtotalcomments = $(".loadmore").attr("id"); //total comments before any inserts or deletes
    initialtotalcomments = parseInt(initialtotalcomments);
    if (initialtotalcomments <= 10) {
        $(".loadmore").hide();
    }
    if (initialtotalcomments >= 11) {
        $(".loadmore").show();
        $("#commentview").html(10 + " of ");
        $("#commentcount").html(initialtotalcomments);
    }
    $(".loadmore").click(function(e) {
        e.preventDefault();

        $.post("ajax/commentcount.php?id=" + pid, function(actualtotalcount) {
            var commentviewcountbeforeclick = $('.date').length; //number of comments displayed on page before more click. varies due to inserts or deletes before click of more button. each insert increases it by 1. each delete decreases it by 1.
            actualtotalcount = parseInt(actualtotalcount);
            //keeps track of actual total comment count adjusted for inserts and deletes
            var end = commentviewcountbeforeclick + 10;
            $(".loading").show();
            $.post("ajax/pull.php?id=" + pid, {
                end: end
            }, function(data) {
                $("#commentarea").html(data);
                $('.confirmdelete').hide();
                $(".loading").hide("slow");
                var commentviewafterclick = $('.date').length; //number of comments displayed on page after click(= to commentviewbeforeclick + num)
                if (actualtotalcount >= 11) {
                    $("#commentview").html(commentviewafterclick + " of ");
                    $("#commentcount").html(actualtotalcount);
                }
                if (commentviewafterclick == actualtotalcount) {
                    $(".loadmore").hide();
                }
            });
        });
    });
});
4

2 に答える 2

0

38 行目と 40 行目に;. radixs にもパラメータを指定する必要がありますparseInt。そうしてみると、おそらく IE が動作するようになるでしょう。

編集:またactualtotalcount、複数回初期化します。

于 2012-03-28T16:23:47.873 に答える
0

かなり死んでいる投稿を復活させるわけではありませんが、まったく同じエラーに遭遇しました。私が遭遇した問題は、私が渡していた投稿パラメータにオブジェクトが含まれていたことです(私の場合はlocationオブジェクトでした)。文字列 URL に切り替えると、問題は解決しました。

$.post()or$.getJSON()呼び出しに空のオブジェクトを渡してもエラーが発生しない場合は、渡したパラメーターを確認してください。

お役に立てれば。

于 2016-12-12T18:06:04.713 に答える