Data table working on localhost but not online server
Data table working on localhost but not online server
Jatin
Posts: 2Questions: 1Answers: 0
I am using server side datatables.
I am able to run my script on localhost successfully but online it's not working.
My server side function
function addevents()
{
$table = 'mov_wsmovies_events';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'title', 'dt' => 'title' ),
array( 'db' => 'profile_image', 'dt' => 'profile_image',
'formatter' => function( $d, $row ) {
//$src = $base.'/'.$d;
$src = JURI::root().$d;
return "<img src='$src' width='50px' height='50px'>
";
}
),
array( 'db' => 'cover_image', 'dt' => 'cover_image',
'formatter' => function( $d, $row ) {
$src = JURI::root().$d;
return "<img src='$src' width='60px' height='40px'>
";
}
),
array(
'db' => 'id',
'dt' => 'action',
'formatter' => function( $d, $row ) {
return "<a href='#' onclick='funedit($d)'><i class='fa fa-pencil-square-o' aria-hidden='true'></i></a> <a href='#' onclick='fundelete($d)'><i class='fa fa-trash' aria-hidden='true'></i></a> <a href='index.php?option=com_wsmovies&Itemid=604&view=addevents&model=addevents&layout=manage_pricings&eventId=".$d."'><label class='label label-primary'>Manage pricings</label></a>
";
}
)
);
$sql_details = $this->db_details();
$where = "id =1";
$user = JFactory::getUser();
$user_id = $user->id;
$res = DatatableHelper::complex( $_GET, $sql_details, $table, $primaryKey, $columns, null,"user_id = $user_id" );
echo json_encode($res);
die;
}
My client side function
var eventTable;
$(document).ready(function() {
eventTable = $('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "<?php echo JRoute::_('index.php?option=com_wsmovies&task=addevents' ); ?>",
"columns": [
{ "data": "title" },
{ "data": "profile_image" },
{ "data": "cover_image" },
{ "data": "action" },
],
} );
$('#example_length select').css("display", "inline");
$('#example_filter input').css("display", "inline");
} );
I am getting error like
DataTables warning: table id=exampleone - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Please somebody help me to solve this issue.
This discussion has been closed.