I want to update a database field when a user presses the Facebook Like button.
A small snippet of my code below. I’ve simplified it, so plz don’t start about the errors/bad practices 😉
<?php
function updateLike () {
mysql_query("UPDATE like SET liked = '1'");
}
?>
<script>
FB.Event.subscribe('edge.create', function(response) {
<?php updateLike() ?>
});
</script>
So, that doesn’t work. I’ve read something about making an AJAX call but I couldn’t find a good example for my situation.
Who can push me in the right direction?
Yes, you can update db using ajax
Script
server.php
You can do update or whatever the server process
You can get easy make ajax call easily using jQuery.