2012-03-28 223 views
-1

您好,我无法使下面的jQuery脚本在Internet Explorer中工作。更多按钮不响应。我找不到任何小的语法错误,等等有人能够帮助我改变脚本,所以它在IE上工作。如果我在兼容模式下运行IE,它可以工作。谢谢。jquery在FF,铬和Safari浏览器中工作,但不是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(); 
       } 
      }); 
     }); 
    }); 
}); 
+0

_“我在制作下面的jQuery脚本在Internet Explorer中工作时遇到了麻烦”_ **这并没有多说!** – gdoron 2012-03-28 16:20:37

+0

更多按钮不响应 – Anonymous 2012-03-28 16:22:36

+0

您是否在JavaScript控制台中看到错误? – JJJ 2012-03-28 16:29:27

回答

0

第38行和第40行添加一个;。您还应该在parseInt中指定radix参数。试着这样做,也许IE会表现出色。

编辑:您还多次初始化actualtotalcount

+0

对不起,我重新格式化的代码,所以你的行号可能是关闭的。基本上,他们需要在'$ .post()'调用后';'。 – 2012-03-28 16:26:11

+0

我做了除基数参数之外的所有更改...仍然需要查看是什么。仍然没有工作。 javascript控制台产生以下错误 SCRIPT65535:无效的调用对象 jquery.js,第3行字符31871 – Anonymous 2012-03-28 16:41:20

0

不是要复活一个相当死的帖子,但我碰到了这个完全相同的错误。我遇到的问题是我传递的参数后面有一个对象(在我的情况下,它是一个location对象)。切换到一个字符串URL解决了这个问题。

如果你传递一个空对象为$.post()$.getJSON()呼叫并没有得到错误,看看你传递。

希望这有助于PARAMS。

相关问题