Hi,
I'm using Laravel 5.4 with DataTable 8.0, on localhost everything working well and DataTable all ok. However, When I upload my files on "digital ocean" online server, Datatable working but for Pagination not working completely. It shows all records (6420 records) per each slide of pagination. On localhost it shows 10 records per page as normal, but online it shows all records in each slide of pagination.
Another problem which is the search box, which not working at all. It shows processing in every typing for any text inside it. However, no results after typing anything inside it.
Here in my code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<link href="-------/css/custom.css" rel="stylesheet" type="text/css">
<link href="-------/css/all.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link href="https://fonts.googleapis.com/css?family=Dosis:300,400,500,700" rel="stylesheet">
<link href="-------/assets/plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
<link href="-------/assets/plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css">
<link href="-------/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="-------/assets/css/icons.css" rel="stylesheet" type="text/css" />
<link href="-------/assets/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="-------/js/canvasjs.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
</head>
Here in my HTML body:
<table id="datatable" class="alldata table table-striped table-bordered"
cellspacing="0" width="100%">
<thead>
<tr>
<th style="vertical-align:middle">
<center>Lead</center>
</th>
<th style="vertical-align:middle">
<center>Email</center>
</th>
<th style="vertical-align:middle">
<center>Phone</center>
</th>
<th style="vertical-align:middle">
<center>Show</center>
</th>
<th style="vertical-align:middle">
<center> Type</center>
</th>
<th style="vertical-align:middle">
<center> Stage</center>
</th>
<th style="vertical-align:middle">
<center> Source</center>
</th>
<th style="vertical-align:middle">
<center> Status</center>
</th>
<th style="vertical-align:middle">
<center> SMS</center>
</th>
<th style="vertical-align:middle">
<center>Assign</center>
</th>
<th style="vertical-align:middle">
<center>Remark</center>
</th>
</tr>
</thead>
</table>
Js and footer :
<script>
$(document).ready(function () {
$('.alldata').DataTable({
processing: true,
serverSide: true,
ajax: {
url: "lead/GetAllLeads"
},
columns: [
{"data": "name", "name": "name"},
{"data": "primary_number", "name": "primary_number"},
{"data": "email", "name": "email"},
{"data": "source_id", "name": "source_id"},
{"data": "company_name", "name": "company_name"},
{"data": "cust_comp_id", "name": "cust_comp_id"},
{"data": "created_at", "name": "created_at"},
{"data": "updated_at", "name": "updated_at"},
{"data": "pro_number", "name": "pro_number"},
{"data": "attention_s", "name": "attention_s"},
{"data": "id", "name": "id"}
],
bSort: true,
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
)};
I get the data right from Controller, but my problem in showing the DataTable on "digital ocean" server, it keep showing all response records (6320 records) in each slide of pagination, which make the page too long and the pagination need a time to load. I want to make it work as normal, 10 records per page, is there any conflict or library missed.
Another problem, Search box showing processing in every typing, but not working and no results affected.
Any help please,
i had a kinda similar behaviour with php 7.2 & 9.0 version
the problem was a bad nginx config
i had
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php$query_string;
}
but it had to be (check the ? mark between index.php and $query_string
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
@TomMeijnaerts might be correct. There are some instances where server config causes an issue.
try_files $uri $uri/ /index.php?$query_string;
You saved my day, Sir!
very good, I've spent two days trying to figure this out.
This worked for me.
try_files $uri $uri/ /index.php?$query_string;
thank you,
Most helpful comment
i had a kinda similar behaviour with php 7.2 & 9.0 version
the problem was a bad nginx config
i had
but it had to be (check the ? mark between index.php and $query_string