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>