Uncaught TypeError: Cannot read property 'style' of undefined in datatable
Uncaught TypeError: Cannot read property 'style' of undefined in datatable
smitashinde0104
Posts: 1Questions: 1Answers: 0
Hello, When i am double clicking filter button then this error will be come. Can anyone please help me to resolve this problem?
here is my code,
1] This is my table structure:
2] here is my action.php code:
if(isset($POST['action']) && $_POST['action'] == 'example_dataTable'){
$todate = $_POST['todate'];
$fromdate = $_POST['fromdate'];
// echo $fromdate."".$todate;die;
$from_split = explode("-",$fromdate);
$from = $from_split[2].'-'.$from_split[1].'-'.$from_split[0];
$from = $from.' 00:00:00';
$to_split = explode("-",$todate);
$to = $to_split[2].'-'.$to_split[1].'-'.$to_split[0];
$to = $to.' 23:59:59';
// session_start();
// $userid = $_SESSION['userid'];
$query = mysql_query("select * from cdrm_recharge where insert_date between '".$from."' and '".$to."'");
$num = mysql_num_rows($query);
$response = array();
if($num > 0){
while($rec = mysql_fetch_assoc($query)){
$response[] = array(
'id' => $rec['recharge_id'],
'member_id' => $rec['member_id'],
'operator_id' => $rec['operator_id'],
'recharge_amount' => $rec['recharge_amount'],
'date' => $rec['insert_date']
);
}
}
$results = array(
"sEcho" => 1,
"iTotalRecords" => count($response),
"iTotalDisplayRecords" => count($response),
"aaData"=>$response
);
echo json_encode($results);
}
3] here is my js code where i'm create function for fetching database values:
$(document).ready(function() { // rechistoryTable(); $('#example').DataTable(); $('.date-picker').datepicker({ defaultDate: "+1w", format: 'dd-mm-yyyy', endDate: '+0d', autoclose: true }); rechistoryTable(); $("#recharge_filter").click(function(){ // alert(1); rechistoryTable(); }); } ); function rechistoryTable(){ var fromdate = $("#dateform").val(); var todate = $("#dateto").val(); // alert(fromdate); // alert(todate); var data= {action:"example_dataTable",fromdate:fromdate,todate:todate} return $('#example').DataTable( { "responsive": true, // "bProcessing": true, "destroy": true, "paging": true, "bInfo" : false, "order": [[ 0, "desc" ]], "aoColumns": [ { mData: 'id' }, { mData: 'member_id' }, { mData: 'operator_id' }, { mData: 'recharge_amount' }, { mData: 'date' }, ], "ajax": { 'type': 'POST', 'url': 'action.php', 'data': data, }, }); }This discussion has been closed.