get可以,post提交失败,求解。
routes.php配置
Route::match(['get', 'post'], 'getlist/', 'Admin\UserController@getList');
post 的时侯返回是 Content-type:text/html; charset=UTF-8
但get的返回是 Content-Type:application/json
代码就是这向句了
public function getList()
{
$array=[];
$user = DB::table('users')->paginate(15);
$array['page']=$user->currentPage();
$array['rows']=$user->items();
$array['total']=$user->total();
return response()->json($array);
}
Route::match(['get', 'post'], 'getlist/', 'Admin\UserController@getList');
post 的时侯返回是 Content-type:text/html; charset=UTF-8
但get的返回是 Content-Type:application/json
代码就是这向句了
public function getList()
{
$array=[];
$user = DB::table('users')->paginate(15);
$array['page']=$user->currentPage();
$array['rows']=$user->items();
$array['total']=$user->total();
return response()->json($array);
}
1 个回复
yuzhahui
赞同来自:
--------------------------修改VerifyCsrfToken[ App\Http\Middleware]
---------------------------------------------------
$routes里就是允许的路径了 laravel-v 5.1.4