Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up some voting logic on my site, and have the vote result update without refreshing the site. I did some research and AJAX seems to be the way to go, but I can't find a good tutorial on it.

I'm doing the update to Mysql

$query = "update RR_upload set vote = vote".$vote." where id = '".$var1."'";
mysql_query($query, $connection) or die (mysql_error());

How do I make it so AJAX updates the content of the site after running the vote update?

share|improve this question

closed as off topic by Jeff Atwood Aug 16 '10 at 10:29

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

definitely a programming question – Jeff Atwood Aug 16 '10 at 10:29
up vote 1 down vote accepted

This question may be a better fit for StackOverflow.

This tutorial should help you get going: http://articles.sitepoint.com/article/ajax-jquery

Basically, AJAX will invoke a server side script that updates the DB and returns the new state of the poll.

When the AJAX query is made a function is assigned for the call back (AJAX is asynchronous so you have to assign a Javascript function that will be run when the response comes back) that happens once the server side script returns. The callback function then updates the HTML page with the new info.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.