-1

Hi I am having trouble making the below jquery script work in Internet explorer. The more button doesnt respond. I can't find any small syntax errors, etc. Would someone be able to help me change the script so it does work on IE. If I run IE in compatibility mode it works. Thanks.

$(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();
                }
            });
        });
    });
});
Anonymous
  • 179
  • 2
  • 3
  • 10

2 Answers2

0

Not to resurrect a fairly dead post but I just ran into this exact same error. Problem I was running into was the post params I was passing had an object in it (in my case it was a location object). Switching to a string URL solved the problem.

If you pass an empty object into the $.post() or $.getJSON() call and don't get the error, take a look at the params you are passing in.

Hope this helps.

creativekinetix
  • 357
  • 1
  • 7
0

Line 38 and line 40, add a ;. You should also specify a radix parameter in your parseInts. Try doing that, and perhaps IE will behave.

Edit: You also initialize actualtotalcount more than once.

wanovak
  • 6,117
  • 25
  • 32
  • Sorry, I reformatted the code, so your line numbers are probably off. Basically, they need `;` after the `$.post()` calls. – Jeff B Mar 28 '12 at 16:26
  • i made all the changes except the radix paremeter... still have to look up what that is. still doesnt work. the javascript console is producing the following error SCRIPT65535: Invalid calling object jquery.js, line 3 character 31871 – Anonymous Mar 28 '12 at 16:41