Skip to content

Instantly share code, notes, and snippets.

@vgheri
Created June 4, 2012 17:50
Show Gist options
  • Save vgheri/2869817 to your computer and use it in GitHub Desktop.
Save vgheri/2869817 to your computer and use it in GitHub Desktop.
register vote
function registerVote(star, postUrl) {
var votedImage = $(".active img");
// If the user didn't vote yet, then we can register the vote
if (votedImage.data("vote") === null || votedImage.data("vote") === undefined) {
$(".carousel-vote-title").text("Submitting your vote...");
$.ajax({
type: 'POST',
url: postUrl,
data: '{"imageId":"' + votedImage.attr("id") + '", "rating":"' + star.attr("id") + '"}',
contentType: "application/json; charset=utf-8",
success: function (msg) {
votedImage.data("vote", msg);
preloadRating();
},
error: function () {
alert("Ooops, an error has occurred. Please try again and if the problem persists... well it's just a proof of concept app, what did you expect?");
resetStarContainer();
return false;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment