No data in Ajax request
No data in Ajax request
![Hildeb67](https://secure.gravatar.com/avatar/eff90f4a07179300873686a5d6ba3ce4/?default=https%3A%2F%2Fvanillicon.com%2Feff90f4a07179300873686a5d6ba3ce4_200.png&rating=g&size=120)
in DataTables 2
Hello everyone,
I have an application with DataTable and MySQL connection via Ajax.
Now I had to move the whole thing to a new server.
Since then I have no longer received any responses (data) back.
A mysqli_query query works, so the data connection is also there.
What could be the reason?
Here is a code snippet:
const einsatzneu = new DataTable.Editor({
ajax:{
url: "/FOM/controllers/einsätze_bearbeiten.php",
type: 'post',
data: { feuerwehrid: js_variable_feuerwehrid,feuerwehrname: js_variable_feuerwehrname}
},
table: "#fweinsätze",
template: '#einsatz',
fields: [
{
label: "EINSATZID:",
name: "EINSATZID"
},
{
label: "FWID:",
name: "FWID",
},
{
label: "ESNR:",
name: "ESNR",
}
],
formOptions: {
inline: {
onBlur: 'submit'
}
}
});
var tableeinsatz = $('#fweinsätze').DataTable( {
"language": {
url: "./resources/ger.json"
},
dom: '<"top"<"left-col"B><"center-col"l><"right-col"f>>rtip',
ajax:{
url: "/FOM/controllers/einsätze_bearbeiten.php",
type: 'post',
data: { feuerwehrid: js_variable_feuerwehrid,feuerwehrname: js_variable_feuerwehrname}
},
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "EINSATZID",visible: false},
{ data: "FWID",visible: false},
{ data: "ESNR"}
],
Here is a code snippet from my Server-Script:
<?php
include( dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DataTables.php');
$fwname = $_POST['feuerwehrname'];
$fwid = $_POST['feuerwehrid'];
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
Editor::inst( $db, 'ffweinsatz' )// Tabelle aus Datenbank
->fields(
Field::inst( 'EINSATZID' ),
Field::inst( 'FWID' ),
Field::inst( 'ESNR' )
)
->where( 'FWID', $_POST['feuerwehrid'])
->debug(true)
->process( $_POST )
->json();
Attached is the network status
This question has an accepted answers - jump to answer
Answers
Try adding:
at the top of the
einsätze_bearbeiten.php
file. That will hopefully cause an error to show.It is worth noting that Editor's PHP libraries use a PDO connection, not mysqli.
Allan
Hi allan,
here is the error message
Warning: require(/usr/www/users/feuerwcs/FOM/lib/Editor.php): Failed to open stream: No such file or directory in /usr/www/users/feuerwcs/FOM/lib/Bootstrap.php on line 38
Fatal error: Uncaught Error: Failed opening required '/usr/www/users/feuerwcs/FOM/lib/Editor.php' (include_path='.:/usr/local/lib/php/') in /usr/www/users/feuerwcs/FOM/lib/Bootstrap.php:38 Stack trace: #0 /usr/www/users/feuerwcs/FOM/controllers/einsätze_bearbeiten.php(28): DataTables{closure}() #1 {main} thrown in /usr/www/users/feuerwcs/FOM/lib/Bootstrap.php on line 38
Hi allan,
I have now found the error. When copying the directories, the Editor.php file was missing from the lib directory.
I copied this in and now it works. Thank you for the quick help. Many greetings, Chris
Excellent - great to hear that you found the problem.
Regards,
Allan