Hey guys, I am very new to AJAX and and working on a rating script, but I want to be able to pass multiple values back into my ajax function :
Right now it runs a to a php script called ratings, where it takes the total value of votes / votes and multiplies it by the width of each start to get an accurate current rating. What I'd like to do is also pass back the amount of votes so I can display them. I know how I could do this by making another function but that seems redundant and not very efficient.
My question is, is it possible to pass back not only the width (value / votes * 22) for my rating box, but also the total # of votes in 1 query. If not the better question would it be better to pass back a string in jquery that already has the votes & value, and do the width calculation with java script ?
$(document).ready(function() {
getRating();
function getRating(){
$.ajax({
type: "GET",
url: "../includes/rating.php",
data: "action=get&bookid="+$("#current").attr("value"),
cache: false,
async: false,
success: function($rating) {
$("#current").css({ width: "" + $rating });
},
error: function(result) {
alert("Error");
}
});
}
Thanks!