Hi. I want to load a table by a parameter something like this

Hi. I want to load a table by a parameter something like this

Hildeb67Hildeb67 Posts: 67Questions: 19Answers: 1

$(document).ready(function() {

$(document).on("click", "#anzeigekw", function () {
var kw = document.getElementById("kwoche").value;

$.ajax( {
  url: './controllers/testcontroller.php',
  type: "POST",
  dataType: 'json',
  data: { kw: kw }
    } );

    .... the i want to load the Table

} );


testcontroller.php

<?php
include("../lib/DataTables.php" );
require_once 'index.php' ;

$action = $_REQUEST['action'];
session_start();

if ($action == "getkw") {
$kw = (!empty($_GET['kw'])) ? $_GET['kw'] : '';
}

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 = Editor::inst( $db, $kw )
->fields(
Field::inst( 'Klasse' ),
Field::inst( 'KNachname' ),
Field::inst( 'KVorname' ),
Field::inst( 'Mo_geht' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Bitte Uhrzeit eingeben' )
) )
->validator( 'Validate::dateFormat', array(
"format" => ( 'H:i' ),
'message' => 'Uhrzeit nicht gültig'
) ),
Field::inst( 'Mo_mitbus' )
->setFormatter( function ( $val, $data, $opts ) {
return ! $val ? 0 : 1;
} ),
Field::inst( 'Mo_bus' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Bitte Uhrzeit eingeben' )
) )
->validator( 'Validate::dateFormat', array(
"format" => ( 'H:i' ),
'message' => 'Uhrzeit nicht gültig'
) ),
Field::inst( 'Mo_mitessen' )
->setFormatter( function ( $val, $data, $opts ) {
return ! $val ? 0 : 1;
} ),
Field::inst( 'Mo_haus' )
->setFormatter( function ( $val, $data, $opts ) {
return ! $val ? 0 : 1;
} )

)
->debug(true)   
->process( $_POST )
->json();   
<?php > ?>

can someone help me?
Thanks

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Looks like you are using jQuery ajax() to fetch the data. Use the success function to initialize and load the data using the data option.

    Kevin

Sign In or Register to comment.