Jump to content

Ayuda con este systema ajax


chapolox
 Share

Recommended Posts

Miren tengo un problema en la web y es que quiero poner un limite de tiempo para el sistema de votacion; Explico mejor,  un usuario puede votar las veces que quiere en un mismo dia y al menos para evitar eso me gustaria ponerle un tiempo de 4 o 5 horas para poder votar de nuevo 

 

 

aqui el code

 

 

$(document).ready(function(){
// ajax setup
$.ajaxSetup({
url: 'ajaxvote.php',
type: 'POST',
cache: 'true'
});
 
// any voting button (up/down) clicked event
$('.vote').click(function(){
var self = $(this); // cache $this
var action = self.data('action'); // grab action data up/down 
var parent = self.parent().parent(); // grab grand parent .item
var postid = parent.data('postid'); // grab post id from data-postid
var score = parent.data('score'); // grab score form data-score
 
// only works where is no disabled class
if (!parent.hasClass('.enabled')) {
// vote up action
if (action == 'up') {
// increase vote score and color to orange
parent.find('.vote-score').html(++score).css({'color':'green'});
// change vote up button color to orange
self.css({'color':'orange'});
// send ajax request with post id & action
$.ajax({data: {'postid' : postid, 'action' : 'up'}});
}
// voting down action
else if (action == 'down'){
// decrease vote score and color to red
parent.find('.vote-score').html(--score).css({'color':'red'});
// change vote up button color to red
self.css({'color':'red'});
// send ajax request
$.ajax({data: {'postid' : postid, 'action' : 'down'}});
};
 
// add disabled class with .item
parent.addClass('.disabled');
};
});
});
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...