NEW, EDIT, DELETE successfully but with error Undefined variable data
NEW, EDIT, DELETE successfully but with error Undefined variable data
michelek
Posts: 24Questions: 5Answers: 0
Hi all,
I have this big problem.
I have added in the ajax query an ID to send to the db.php file but with this method datatables give me an error.
What I can do?
This is my code:
dialog.php
<?php
$id = $_REQUEST['id'];
echo $id;
<?php
>
?>
var editor5;
var ids = <?php echo $id; ?>;
$(document).ready(function() {
editor5 = new $.fn.dataTable.Editor( {
"bServerSide": true,
ajax: "php/manutenzione2_db.php",
table: "#example5",
fields: [ {
label: "First name:",
name: "manutenzione_SUBCAT.id"
}, {
label: "Last name:",
name: "manutenzione_SUBCAT.nome"
} , {
label: "ids",
name: "manutenzione_SUBCAT.id_manutenzione_CAT2",
type: 'hidden',
def: ids
}
]
} );
$('#example5').DataTable( {
dom: "Bfrtip",
"bServerSide": true,
ajax: {
url: "php/manutenzione2_db.php?IDS="+ids,
type: 'POST'
},
columns: [
{ data: "manutenzione_SUBCAT.id" },
{ data: "manutenzione_SUBCAT.nome" }
],
select: true,
buttons: [
{ extend: "create", editor: editor5 },
{ extend: "edit", editor: editor5 },
{ extend: "remove", editor: editor5 }
]
} );
} );
</script>
<div><p></p></div>
<table id="example5" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>NOME</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>NOME</th>
</tr>
</tfoot>
</table>
AND db.php
if (isset($_GET['IDS'])) {
$ID_MANUTENZIONE = $_REQUEST['IDS'];
}
Editor::inst( $db, 'manutenzione_SUBCAT' )
->field(
Field::inst( 'manutenzione_SUBCAT.id' ),
Field::inst( 'manutenzione_SUBCAT.nome' ),
Field::inst( 'manutenzione_SUBCAT.id_manutenzione_CAT2' )
)
->where( 'id_manutenzione_CAT2', $ID_MANUTENZIONE)
->process($_REQUEST)
->json();
This discussion has been closed.
Replies
I found a solution with SESSION but it's not really elegant.
dialog.php:
db.php
We discussed this by e-mail also - it looks like you are not submitting the
IDS
parameter as part of the Editor Ajax request. I would suggest you add that GET parameter to the Ajax URL if you want to successfully use that for both DataTables and Editor Ajax requests.Allan