I have this script

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

jQuery("#add").click(function () {
    type: "POST",
    url: "data.php",

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?