1、ajax请求路由如下:
`
Route::get('/admin/coring','CoringController@alltimeinfo');
`
2、admin/CoringController alltimeinfo()方法:
`
public function alltimeinfo() {
if(request()->ajax()) {
return responce()->json(['test' => 'test1']);
}
}
`
3、ajax js
`
已添加: <meta name="csrf-token" content="{{ csrf_token() }}">
$.ajax({
url: "{{url('admin/coring/alltimeinfo')}}",
data: {},
type: 'get',
async: true,
// 跨域请求时同时发送自身cookie
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
},
success: function (data) {
`
4、始终报500错误:
`
(1/1) BadMethodCallException
Method [show] does not exist.
`
5、关闭过kernel.php的csrf验证,并在VerifyCsrToken.php里过滤掉请求路由,好像没有用,是路由写的问题吗?提示CoringController里面找不到show()函数??
你路由定义的是
Route::get('/admin/coring','...');
,ajax
访问的是/admin/coring/alltimeinfo
, 你确定你真的在写程序吗?