Get multiple values through an AJAX query

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!

以上就是Get multiple values through an AJAX query的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏