2009-01-29 13 views

Respuesta

6

Hay muchas secuencias de comandos out there pero no es demasiado difícil hacerlo usted mismo.

He usado jQuery (para manejar AJAX) y una pequeña secuencia de comandos PHP antes. Por ejemplo, algunos pseudo-código:

// Some checking for recent votes from this user is appropriate here 
if (isset($_POST['voteType'], $_POST['postId']) && $user->loggedIn) { 
    // insert vote into database if not already inserted 
    echo json_encode(array('error' => false)); 
} else { 
    // bad request/hack attempt 
    echo json_encode(array('error' => true, 'message' => 'Bad parameters sent')); 
} 

y algo más jQuery:

$('#upVote').click(function() { 
    $.post('vote.php', {voteType: 'up', postId: 42}, 'updateIcon(data, textStatus)', 'json'); 
}); 

function updateIcon(data, textStatus) { 
    // If error = false highlight the upvote icon 
    // else show the error message returned 
} 

jQuery.post

Cuestiones relacionadas