Q:

How does this AJAX script pass a variable via post to the PHP script?

I am going through this tutorial
http://www.9lessons.info/2009/04/exactly-twitter-like-follow-and-remove.html
on how to implement a twitter-like follow/unfollow button.
I am also completely new to AJAX and so I am kind of figuring it out as I go along.
Usually one passes variables through a form and sets the action to POST and then does stuff with PHP.
Here however, there is this section of javascript (for following a user)
<script type="text/javascript" >
$(function() 
{
    $(".follow").click(function(){
        var element = $(this);
        var I = element.attr("id");
        var info = 'id=' + I;
        $("#loading").html('<img src="loader.gif" >');

        $.ajax({
            type: "POST",
            url: "follow.php",
            data: info,
            success: function(){
                $("#loading").ajaxComplete(function(){}).slideUp();
                $('#follow'+I).fadeOut(200).hide();
                $('#remove'+I).fadeIn(200).show();
            }
        });
        return false;
    });
});
</script>

and  say we have this section of html/php
<?php
$sql=mysql_query("Some SQL Statement that grabs users");
while($row=mysql_fetch_array($sql))
{
    $id=$row["user_id"];
?>
<div id="follow<?php echo $id;?>">
    <a href="#" class="follow" id="<?php echo $id;?>">
    <span class="follow_b"> Follow </span></a>
</div>
<div id="remove<?php echo $id;?>" style="display:none"> 
    You Following <a href="#" class="remove" id="<?php echo $id;?>">
    <span class="remove_b"> remove </span></a>
</div>
<?php
}
?>

What is the POST variable needed by follow.php called? What does "success" do and how does it interact with follow.php?

A:

PHP will receive a POST variable called 'id', which has the value that was stored in the page element with id ID.
The success handler is a script construct saying 'execute this code if the ajax request succeeded'. There's also an 'error' equivalent which only executes if something blew up. success by itself does not interact with PHP. It's simply some code that happens to be run if the PHP script does not return an error code.
Many ajax scripts indicate success/failure by manipulating the HTTP error code of the response. 2xx = everything ok, invoke the success handler. Anything 4xx or 5xx would invoke the error handler.

