
February 5th, 2013, 07:20 AM
|
 |
Contributing User
|
|
Join Date: Sep 2012
Posts: 148
Time spent in forums: 18 h 39 m 9 sec
Reputation Power: 1
|
|
|
Can Jquery Ajax check if a Query succeeded?
I'm using Ajax to update a text in my database but I'm wondering if php can send a response back with Ajax if the Query is succesfull
Code:
$.ajax({
type: 'POST',
url: 'test.php',
data: 'text=' + text,
and on my test.php page
Code:
if($_POST){
try {
$insert_query = $db->prepare('UPDATE fields SET content = :content WHERE name = "homepage_mission" ');
$insert_query->execute(array('content' => $_POST['text']));
}
catch(PDOException $e){
print $e->getMessage();
die();
}
}
Help would be loved! thanks
|