
// Delete record $(document).on("click","."+deletebutton,function(){ var id = $(this).attr("id"); var idDeliver = $('#deliverId').val(); if(id){ if(confirm("Napewno chcesz usunąć ten wiersz? Usuwanie będzie NIEODWRACALNE! ID Pro: "+id+" ID Deliv: "+idDeliver)) ajax("iddd="+idDeliver+"&rid="+id,"del"); } }); ajax = function (params,action){ $.ajax({ type: "POST", url: "php/ajax_deliverAdd.php", data : params+"&action="+action, dataType: "json", success: function(response){ switch(action){ ... case "del": var seclastRow = $("."+table+" tr").length; console.log("jestesmy w case del sekces"); if(response.success == 1){ $("."+table+" tr[id='"+response.id+"']").effect("highlight",{color: '#f4667b'},500,function(){ $("."+table+" tr[id='"+response.id+"']").remove(); }); } break; ... } }, error: function (jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect.\n Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error.\n' + jqXHR.responseText; } console.log(msg); } }); }
oraz ajax_deliverAdd.php:
$action = $_POST['action']; if($action == "del"){ $id = $_POST['rid']; $idD = $_POST['iddd']; $res = $deliverAdd->delete_record($id,$idD); $resultArray["success"] = "1"; // = 1 $resultArray["id"] = $id; // = 1014 // = "1014" //if($res) //else //echo $deliverAdd->error("delete"); }
class.php:
public function delete_record($id,$idD){ $stmt = $this->db->prepare("DELETE FROM `deliveries_products` WHERE `deliveries_id` = :IDd AND `product_id` = :ID"); $stmt->bindParam(':ID', $id); $stmt->bindParam(':IDd', $idD); $stmt->execute(); return true; } function error($act){ }
funkcja z mysql jest poprawna bo usuwa (po odświeżeniu nie ma tego rekordu) tylko ze nie ma animacji na stronie przez ajxa bo nie wchodzi w success tylko error ... i już nie mam pomysłu

