I want to do some modifications on a table with AJAX.
In localhost all is allright but after transfer on production server, 500 Error.
I saw on other topics the problem should be on my .php or with my Apache server.
It's my first time that I use AJAX then I'm not comfortable with this technology.
For example, I want to delete an offer with the Delete button.
My .js :
//Action supprimer
$(".suppr").on("click", function(e){
e.preventDefault();
var conf=confirm("Cette offre sera supprimée, valider ?");
if(conf==true){
var id_promo=$(this).parent().parent().attr('id');
console.log(id_promo);
var ligne=$(this).parent().parent();
var data="op=suppr&id_promo="+id_promo;
var td=($(this).parent());
td.html(ajax_loader);
var request=$.ajax({
url:"ajax_promo.php",
method:"POST",
data:data
});
request.done(function(){
console.log(request);
ligne.empty();
});
request.fail(function(){
console.log(request);
console.log("Fail AJAX");
});
}
});
My .php
/************************ Action bouton "Supprimer" ***************************/
if($_POST["op"]=="suppr" && !empty($_POST['id_promo'])){
$query="UPDATE professionnel_promo"
. " SET online=2"
. " WHERE id=".$_POST['id_promo'];
if(sql_query($query)){
echo "Delete OK";
}
else{
echo "Fail Delete";
}
}
Thanks for help :)