时间:2021-07-01 10:21:17 帮助过:19人阅读
routes.php
Route::group(['middleware' => 'web'], function () {
Route::auth();
//这个url使用post报错
Route::get('/index/folder', "IndexController@folder");
});
controllder
public function folder(Request $request, FoldersRepository $FoldersRep) {
return response($request->user()->id);
}
js
$.ajax({
type: 'get',
url: "/index/folder",
data: formData,
success: function (data) {
console.log(data);
debugger
请问这是怎么回事,如何解决?
laravel框架 , 前台使用ajax提交表单数据,
当type: 'get'时,后台可以通过$request->user()->id 获取到用户id,
但是
当type: 'post'时,后台通过$request->user()->id 报错500.
routes.php
Route::group(['middleware' => 'web'], function () {
Route::auth();
//这个url使用post报错
Route::get('/index/folder', "IndexController@folder");
});
controllder
public function folder(Request $request, FoldersRepository $FoldersRep) {
return response($request->user()->id);
}
js
$.ajax({
type: 'get',
url: "/index/folder",
data: formData,
success: function (data) {
console.log(data);
debugger
请问这是怎么回事,如何解决?