Mobile app version of vmapp.org
Login or Join
Kevin317

: How to using ajax for voting script 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

@Kevin317

Posted in: #Ajax #Mysql #Php

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

This question may be a better fit for StackOverflow.

This tutorial should help you get going: 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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme