Updating Database from Javascript by calling PHP script

后端 未结 1 1103
小蘑菇
小蘑菇 2021-01-14 05:05

Ive been trying to get this for age

I am building a website which has an activity wall. I have the whole thing working except the like and unlike buttons. I have the

相关标签:
1条回答
  • 2021-01-14 05:16

    try this

    <script type="text/javascript">
    function process(LikeId) { 
    //your validation code
    $.ajax( {
            type: 'POST',
            url: LikeUnlike.php, //file where like unlike status change in database
            data:{like:LikeId},
            success: function(data) {
                //code you want to do after successfull process
            }
        } );
    }
    </script>
    

    make changes in html

    <a href='Javascript:void(0)' onclick='process(1)'>Like</a>
    <a href='Javascript:void(0)' onclick='process(0)'>Unlike</a>
    
    0 讨论(0)
提交回复
热议问题