2011-01-27 100 views
0

我使用此jQuery代碼對我的網站中的新聞作者投票。JQuery投票問題

<script type="text/javascript"> 
    $(function() { 
     $(".vote").click(function() 
     { 
      var id = $(this).attr("id"); 
      var name = $(this).attr("name"); 
      var dataString = 'id='+ id ; 
      var parent = $(this); 

      if (name=='up') 

      { 
       $(this).fadeIn(200).html('<img src="dot.gif" />'); 
       $.ajax({ 
        type: "POST", 
        url: "up_vote.php", 
        data: dataString, 
        cache: false, 

        success: function(html) 
        { 
         parent.html(html); 
        } 
       }); 

      } 
      else 
      { 
       $(this).fadeIn(200).html('<img src="dot.gif" />'); 
       $.ajax({ 
        type: "POST", 
        url: "down_vote.php", 
        data: dataString, 
        cache: false, 

        success: function(html) 
        { 
         parent.html(html); 
        } 
       }); 

      } 
      return false; 
     }); 
    }); 
</script> 

這工作!投票後顯示警告框表示感謝或結果。現在,如果在一個頁面9個帖子(例如ADMIN發佈)投票9顯示9個警報框!

如何解決這個問題?

+0

不知道我完全理解這一點。您是否想要根據價值輸入顯示不同的警報?或取決於帖子/類型? – Alex 2011-01-27 14:51:05

回答