talhaMalik22
talhaMalik22

Reputation: 155

how can i make alerts using js after inserting some data through php

I am inserting some information to my database and i am using the following pattern main page has a form. I send values entered in the form to controller and then insert it to database and back to my main page using header(location:../etc).
What i want is that whenever i add some data in my db i want to show some alert that data has been added or anything to give feedback to user.
Can someone suggest me a solution.

Thanks

Upvotes: 0

Views: 312

Answers (1)

hackartist
hackartist

Reputation: 5264

You can use Ajax. I suggest using jQuery because then you can just pass a callback function to the get request which it will call when it gets the return. For example:

 $.get("insertToDB.php", function(data){alert("Data Loaded: " + data);});

Upvotes: 2

Related Questions