Skip to content Skip to sidebar Skip to footer

Updating Database From Javascript By Calling PHP Script

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 them currently jus

Solution 1:

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>

Post a Comment for "Updating Database From Javascript By Calling PHP Script"