Use PHP + jQuery when click on a button -
i have button on page :
<button class="play"></button>
when click on it, launches video via jquery
$('.play').on('click',function(){ player.play(); });
but want add php code save user id in database when clicks on button.
how can mix php & jquery? i'm not used ajax, solution?
thanks help!
try using ajax
$('.play').on('click',function(){ player.play(); $.ajax({ type: "post", url: "some.php", // php file name data:{id :"id"}, //pass user id success:function(data) { if(data==true) alert("success"); else alert("error"); } }); }
some.php
<?php $success=false; //declare , initialize variable // code update database //and check if database updated , if set $success=true echo $success; ?>
Comments
Post a Comment