Ajax Polling/Voting System with jQuery, Ajax, PHP and MySQL

Surveying framework or Voting framework is extremely regular in sites. Voting could be about your website or site or some other thing simply to get the client consideration and get your thought regarding your item.

Database Structure
Copy this db structure as it is and paste in your mysql window.
CREATE TABLE IF NOT EXISTS `polling` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`liked` int(11) NOT NULL,
`dislike` int(11) NOT NULL,
`average` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


— Dumping data for table `polling`

INSERT INTO `polling` (`id`, `liked`, `dislike`, `average`) VALUES
(1, 1, 1, 1);
CREATE TABLE IF NOT EXISTS `polling_ip` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userip` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
JQUERY CODE
// <![CDATA[
$(document).ready(function() {

$(‘.totalstatsbutton’).livequery(“mouseenter”, function(e){
$(‘.tooltip3’).show();
$(‘.totalstats’).fadeIn(200);
}).livequery(“mouseleave”, function(e){
$(‘.tooltip3’).hide();
$(‘.totalstats’).fadeOut(200);
});
});

$(document).ready(function(){

$(‘#Send’).click(function(){

var vote = $(“input[@name=’radio_name’]:checked”).val();
showLoader();
$.post(“voting.php?value=”+vote,{
}, function(response){
hideLoader();
$(‘#wrap’).html(unescape(response));
});
});

//show loading bar
function showLoader(){
$(‘.search-background’).fadeIn(200);
}
//hide loading bar
function hideLoader(){
$(‘.search-background’).fadeOut(200);
};
});

Download full code

Advertisements

2 thoughts on “Ajax Polling/Voting System with jQuery, Ajax, PHP and MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s