我添加到routes / api.php
Route::get('v1/crosses.json', 'API\BasicController@crosses')
我的front.js包括
require('jquery-typeahead');
$.typeahead({
input: '#search',
source: {
cross: {
ajax: {
type: "GET",
url: 'api/v1/crosses.json',
path: "data.crosses",
dataType: "json",
data: {
term: "11"
}
}
}
}
});
Laravel 5.4 - 控制器
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class BasicController extends Controller
{
public function crosses(Request $request): JsonResponse
{
return response()->json([
"status" => true,
"error" => null,
"data" => [
"crosses" => [
'sample'
]
]
]);
}
}
当我开始在#search字段中写字时,我立即开始查询。只有他们没有达到目标。控制台发出404错误。我认为路由可能有问题,但在route:list
中它显示了这个请求,它也可以在浏览器中打开。只有当通过ajax引用崩溃'找不到'
答案 0 :(得分:0)
我正在使用nginx。回应非常大。需要增加缓冲区的大小
fastcgi_buffers 16 256k;
fastcgi_buffer_size 256k;