JQuery doesen't work after I used the searchbox or I change the page of the table.
JQuery doesen't work after I used the searchbox or I change the page of the table.
Hello everyone,
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" ).bind( "click", function() {
idFact = this.id;
var confirmacio = confirm("Do you want to delete this row? "+idFact);
if(confirmacio){
$.post("operacions/borraFact.php", {idFact: idFact}, null, "json").done(function(data){
alert(data.missatge);
})
}
});
});
Then, the JSon file is this one:
```
<?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);
<?php > ``` ?>I would appreciate any solution or something that could help me to correct the issue!
Thank you!