duandu1377 2010-01-07 06:11
浏览 44

JQuery评级Internet Explorer问题

Now if there is no vote casted yet my rating script will not work in Internet Explorer I would not be able to click the star and have its value entered into the database and displayed on the browser.

But if there is one vote already casted the script will work in Internet Explorer perfectly.

How can I fix this problem so that if there is no votes casted yet Internet Explorer users can be the first to enter the votes?

I think its my JQuery coding giving me the problem so I will display that and my HTML Markup.

I'm using PHP, JQuery and MySQL.

JQuery code

// 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 markup

<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条回答 默认 最新

  • douwei2966 2010-01-07 07:33
    关注

    Answered my own question I figured it out it wasn't even my JQuery code it was my PHP code sorry people. +1 for me :)

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效