php - Get multiple values through an AJAX query -


Hey guys, I am very new to AJX and working on a rating script, but I want to be able to multiply several times. Value back in my Ajax function:

Currently, it gives the rating of a PHP script, where it takes the total value of the vote / vote and multiplies by the width of each beginning to get the exact current rating . What I would like to do, will also give back the amount of votes, so I can show them. I know how I can do that one works out, but it is redundant and not very efficient.

My question is, do I have only the width (value / vote * 22) in the rating box, but there are total # votes in 1 query even if the better question is not to return the string in jquery Better to do, which is already voting and amp; Calculate the width with the value, and java script?

  $ (document) .ready (function () {getRating (); function getRating () {$ .ajax ({type: "GET", Url: "../includes/rating Attr ("value"), cache: incorrect, async: false, breakthrough error: work (results) {warnings (" Error ");}}}} <$ (" # current "). CSS ({width:" + + $ rating});} / Code>  

Thanks!

Yes you can return both values. Use JSON instead of text.

  $ (Document) .ready (function () {getRating (); function getRating () {$ .ajax ({type: "GET", data Type: 'Json', url: "../includes/rating.php", data: "action = get & bookid =" + $ ("# current"). Attr ("value"), cache: incorrect, async : False, success: function (data) {$ ("# current"). CSS ({width: "+ + data .aving}}"; $ ("# votes") html (data.votes).}, Error: Work (result) {warning ("error");}})}}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -