samedi 16 juillet 2016

Add a play count to database using ajax and jquery


When a user clicks .play it should add a play count if it doesn't have class alreadyplayed and then add class .alreadyplayed I am new to AJAX and cant seem to make it work.

$(".play").on('click', function () { 
if (!$(this).hasClass('alreadyplayed')) {
    $.ajax({
    type:'post',
    url:'addplay.php',
    data: songid = $(this).attr('sound_id'),
    }).done {
    $(this).addClass('alreadyplayed');
    }
}); 

Aucun commentaire:

Enregistrer un commentaire