I made a JQuery function the one deletes the row I selected. I know that the option exist in the DataTables option, but I want to do by myself, because I prefer to not use AJAX, just JQuery and JSON. The problem appears when I search some specify row in the datatable with the search option, then I click the button to delete, and nothing happens. The other mistake is when I click to the next page, then, all the rows from that page will not work either.
Do you guys know what this could be?
Here I let my JQuery function:
$(document).ready(function() {
$( ".botFactura" ).click(function(e) {
alert("jkn");
idFact = this.id;
var confirmacio = confirm("Segur que vol esborrar la factura "+idFact);
/*if(confirmacio){
$.post("operacions/borraFact.php", {idFact: idFact}, null, "json").done(function(data){
alert(data.missatge);
})
}*/
});});
Then, I have the JSON file there:
<?php
include("../connexio.php");
$idFact= $_POST['idFact'];
$arrayDatos = array();
if($idFact!=""){
$borrar = 'DELETE FROM factures WHERE id="'.$idFact.'"';
//$connBorr = mysqli_query($conn,$borrar);
$arrayDatos['missatge'] = "Factura ".$idFact." esborrada!";
}else{
$arrayDatos['missatge'] = "No s'ha trobat";
}
echo json_encode($arrayDatos);
?>
I call the $(".botFactura") there:
Finally, I'll upload some graphical example about what's my problem: :The first one, is when the page works correctly
Then,the first issue appears when: I change the page of the table. As we can see, I click and nothing happens
The same issue appears when I try to search some specific row into the search box.
Well, I would really appreciate if someone could help to explain why this is not working! Thank you!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)