JQuery评级Internet Explorer问题

时间:2010-01-07 06:11:21

标签: php jquery internet-explorer

现在,如果没有投票,但我的评级脚本在Internet Explorer中不起作用,我将无法点击星标并将其值输入数据库并显示在浏览器上。

但如果已经投了一票,那么该脚本将完全适用于Internet Explorer。

如何修复此问题,以便在没有投票的情况下,Internet Explorer用户可以率先进入投票?

我认为我的JQuery编码给了我这个问题所以我会显示它和我的HTML标记。

我正在使用PHP,JQuery和MySQL。

JQuery代码

// JavaScript Document
    $(document).ready(function() {

        // get average rating
        getRatingText();
        // get average rating function
        function getRatingText(){
            $.ajax({
                type: "GET",
                url: "update.php",
                data: "do=getavgrate",
                cache: false,
                async: false,
                success: function(result) {
                    // add rating text
                    $("#rating-text").text(result);
                },
                error: function(result) {
                    alert("some error occured, please try again later");
                }
            });
        }

        // get current rating
        getRating();
        // get rating function
        function getRating(){
            $.ajax({
                type: "GET",
                url: "update.php",
                data: "do=getrate",
                cache: false,
                async: false,
                success: function(result) {
                    // apply star rating to element dynamically
                    $("#current-rating").css({ width: "" + result + "%" });
                     // add rating text dynamically
                    $("#rating-text").text(getRatingText());
                },
                error: function(result) {
                    alert("some error occured, please try again later");
                }
            });
        }


        // link handler
        $('#ratelinks li a').click(function(){
            $.ajax({
                type: "GET",
                url: "update.php",
                data: "rating="+$(this).text()+"&do=rate",
                cache: false,
                async: false,
                success: function(result) {
                    // remove #ratelinks element to prevent another rate
                    $("#ratelinks").remove();
                    // get rating after click
                    getRating();
                },
                error: function(result) {
                    alert("some error occured, please try again later");
                }
            });

        });
    });

HTML标记

<ul class='star-rating'>
  <li class="current-rating" id="current-rating"><!-- will show current rating --></li>
  <li id="ratelinks">
        <ul>
              <li><a href="javascript:void(0)" title="1 star out of 10" class="one-star">1</a></li>
              <li><a href="javascript:void(0)" title="2 stars out of 10" class="two-stars">2</a></li>
              <li><a href="javascript:void(0)" title="3 stars out of 10" class="three-stars">3</a></li>
              <li><a href="javascript:void(0)" title="4 stars out of 10" class="four-stars">4</a></li>
              <li><a href="javascript:void(0)" title="5 stars out of 10" class="five-stars">5</a></li>
              <li><a href="javascript:void(0)" title="6 stars out of 10" class="six-star">6</a></li>
              <li><a href="javascript:void(0)" title="7 stars out of 10" class="seven-stars">7</a></li>
              <li><a href="javascript:void(0)" title="8 stars out of 10" class="eight-stars">8</a></li>
              <li><a href="javascript:void(0)" title="9 stars out of 10" class="nine-stars">9</a></li>
              <li><a href="javascript:void(0)" title="10 stars out of 10" class="ten-stars">10</a></li>
         </ul>
    </li>
</ul>

1 个答案:

答案 0 :(得分:0)

回答了我自己的问题我发现它甚至不是我的JQuery代码,这是我的PHP代码对不起的人。给我+1:)