【问题标题】:JQuery Rating Internet Explorer ProblemJQuery Rating Internet Explorer 问题
【发布时间】:2010-01-07 06:11:20
【问题描述】:

现在,如果没有投票但我的评分脚本将无法在 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>

【问题讨论】:

    标签: php jquery internet-explorer


    【解决方案1】:

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

    【讨论】:

    • 如果您的解决方案适用于您在此处提出的问题,您应该发布它。否则,您可能应该关闭/删除它。
    • 考虑通过单击旁边的“勾选”或“检查”图标将此答案标记为“已接受”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-27
    • 2012-12-24
    相关资源
    最近更新 更多