Hello everyone,
When i do an ajax request i go to a php script which does something for me. Either it deletes an record from the db or it doesn't.
If it goes ok. I want to deleted and update my html table. Else I want to show an error message or so.
But in my php I can't do something like
return false;
return true;
I need to echo my result or my message and then my jquery script will do something with it.
But how can I get jquery to do something depending on the outcome?
For example here:
jQuery.ajax({
type: "POST",
data: "id=" +id,
url: "ajax_handler.php",
success: function(msg){
jQuery(tr).remove();
jQuery("div.result").append("<p>"+msg+"</p>");
jQuery("div.result").show();
jQuery("div.result").fadeOut(5000);
},
error: function(msg){
}
and the php code
$id = C_GPC::getPOSTvar("id");
$result ="";
if(isset($id) and ($id > 0)){
$p = new C_product();
$deleted = $p->deleteCategorie($id);
if($deleted){
$result = "ok";
}else{
$result = "not ok";
}
}else{
$result = "not ok";
}
echo $result;
I want to do A when ok and B when not ok. How should i deal with this? });