Jump to content

Ayuda con este systema ajax


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



// ajax setup
url: 'ajaxvote.php',
type: 'POST',
cache: 'true'
// any voting button (up/down) clicked event
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
// change vote up button color to 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
// change vote up button color to red
// send ajax request
$.ajax({data: {'postid' : postid, 'action' : 'down'}});
// add disabled class with .item
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.

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.


  • Recently Browsing   0 members

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