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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -