Hello

I have this script

HTML Code:
<div id = "add">
Add as friend
</div>

<script>
jQuery("#add").click(function () {
    $.ajax({
    type: "POST",
    url: "data.php",
        });
});

 </script>
When the div is clicked in it, it will proccess data.php in real-time and add some data into the database.
I want to do a few things.

1) Check if the data has been added into the database successfully.
2) Change the div contents in real-time if it has been a success.
3) Add a new div notifying the user of the success.

How would I go about doing this?