JSFiddle - React, Tailwind, and code Playground
by kathys2151
HTML
<link rel="stylesheet" href="http://datatables.net/download/build/nightly/jquery.dataTables.css">
<script src="http://datatables.net/download/build/nightly/jquery.dataTables.js"></script>
class.ssp
.... everything else same as docs
return array(
"draw" => intval( $request['draw'] ),
"recordsTotal" => intval( $recordsTotal ),
"recordsFiltered" => intval( $recordsFiltered ),
"data" => self::data_output( $columns, $data )
);
search_processing.php
<?php
$table = 'xxxx';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'company', 'dt' => 'company' ),
array( 'db' => 'street', 'dt' => 'street' ),
array( 'db' => 'city', 'dt' => 'city' ),
array( 'db' => 'state','dt' => 'state')
);
$sql_details = array(
'user' => 'xxxx',
'pass' => 'xxxx',
'db' => 'xxxx',
'host' => 'xxxx' );
require( 'searchClass.php' );
echo json_encode(
SSP::notSoSimple( $_POST, $sql_details, $table, $primaryKey, $columns )
);
JavaScript
$('.search-form form').submit(function() {
$('.search-form form .companyLabel').html('company');
$('.search-form form .streetLabel').html('street');
$('.search-form form .cityLabel').html('city');
$('.search-form form .stateLabel').html('state');
var postdata = $('.search-form form').serialize();
$.ajax({
type: 'POST',
url: 'search_processing.php',
data: postdata,
dataType: 'json',
success: function(msg) {
console.log("success");
window.location='search_display.php';
},
error: function() {
console.log('failure');
}
});
return false;
})