2012-03-28 224 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。

相關問題