Laravel:DataTable服务器端支持的方法
我试图将DataTable用作服务器端,但遇到错误“ 对于此路线不支持GET方法。支持的方法:POST。”。我已经尝试了我发现的所有解决方案,但不幸的是它不起作用。
查看
<table id="loan-details-table" class="table table-striped table-bordered table-sm">
<thead class="thead-global">
</thead>
<tbody></tbody>
</table>
<script type="text/javascript">
//function in calling datatable ajax
function getGeneratedLoanDetails(){
var table = $('#loan-details-table').DataTable({
processing: true,
serverSide: true,
ajax: {
url: '/configurations/penalties/getGeneratedLoanDetails/',
dataType: "json",
type: "POST",
data:{ _token: "{{csrf_token()}}"}
},
columns: [
{ data: '#' },
{ data: 'number' },
{ data: 'name' },
{ data: 'date_granted' },
{ data: 'current_date' },
{ data: 'no_of_days' },
{ data: 'daily_amortization_amount' },
{ data: 'total_amortization_amount' },
{ data: 'total_amount_paid' },
{ data: 'difference' },
{ data: 'days_delay' },
{ data: 'interest_rate'},
{ data: 'penalty_amount'},
{ data: 'action' }
]
});
}
$(document).ready(function(){
//datatable ajax
setTimeout(
function()
{
getGeneratedLoanDetails();
}, 500);
})
</script>
web
Route::post('/configurations/penalties/getGeneratedLoanDetails/', 'Penalty\PenaltyController@getGeneratedLoanDetails');
问题:为什么我在我的视图中已经声明了这个错误,&amp;路线作为帖子?
I am trying to use the datatable as a server side but encountered error "The GET method is not supported for this route. Supported methods: POST.". I already tried all the solutions I've found but unfortunately it didn't work.
View
<table id="loan-details-table" class="table table-striped table-bordered table-sm">
<thead class="thead-global">
</thead>
<tbody></tbody>
</table>
<script type="text/javascript">
//function in calling datatable ajax
function getGeneratedLoanDetails(){
var table = $('#loan-details-table').DataTable({
processing: true,
serverSide: true,
ajax: {
url: '/configurations/penalties/getGeneratedLoanDetails/',
dataType: "json",
type: "POST",
data:{ _token: "{{csrf_token()}}"}
},
columns: [
{ data: '#' },
{ data: 'number' },
{ data: 'name' },
{ data: 'date_granted' },
{ data: 'current_date' },
{ data: 'no_of_days' },
{ data: 'daily_amortization_amount' },
{ data: 'total_amortization_amount' },
{ data: 'total_amount_paid' },
{ data: 'difference' },
{ data: 'days_delay' },
{ data: 'interest_rate'},
{ data: 'penalty_amount'},
{ data: 'action' }
]
});
}
$(document).ready(function(){
//datatable ajax
setTimeout(
function()
{
getGeneratedLoanDetails();
}, 500);
})
</script>
Web
Route::post('/configurations/penalties/getGeneratedLoanDetails/', 'Penalty\PenaltyController@getGeneratedLoanDetails');
Question: Why Im encountering this error even tho I already declared it in my view & route as POST?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试在
url
的末尾删除/
ajax param中的吗?此外,您也可以在路线末端以Laravel代码删除/
。更改
/configurations/fine/getGeneratedLoandetails/
/configurations/fine/getGenerateDloandetails
Can you try removing
/
at the end ofurl
inajax
param? Moreover, you could remove/
at the end of your route in Laravel code too.Change
/configurations/penalties/getGeneratedLoanDetails/
to/configurations/penalties/getGeneratedLoanDetails