Почтовый запрос от typehhead и bloodhound не работает в Laravel 5

Это мой HTML-код:

<input autocomplete="off" type="text" id="chiefComplaintInput" name="chiefComplaintInp" class="typeahead-chiefcomplaint form-control input-circle-right" placeholder="Chief Complaints">

Это мой JQuery Bloodhound и Typeahead код:

var chiefComplaints = new Bloodhound({
datumTokenizer: function(resp) {
return Bloodhound.tokenizers.whitespace(resp.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
wildcard: '%QUERY',
url: "/opd/searchChiefComplaints/",
transform: function(response) {
return $.map(response, function(restaurant) {
return { value: restaurant.name };
});
}
}
});

$('input#chiefComplaintInput').typeahead({
hint: false,
highlight: true,
minLength: 2,
limit: 10
},
{
name: 'chiefComplaints',
display: 'value',
source: chiefComplaints,
templates: {
header: '<h4 class="dropdown">Restaurants</h4>'
}
});

Это маршруты, которые я определил:

Route::get('opd/searchChiefComplaints/{queryParam}', 'OpdController@searchChiefComplaints');

Это код контроллера:

public function searchChiefComplaints(Request $request)
{
// return Response::json($request->get('queryParam'));
return $request->get('queryParam');
}

То, что я пытаюсь достичь, — это то, что я хочу отправить запрос на пост контроллера и получить JSON в ответ. Но у меня проблемы с его получением, я не знаю, где мой код работает неправильно 🙁

0

Решение

Опубликованные данные в формате JSON не могут быть прочитаны $request->get(), Вы должны использовать $request->input(),

Смотрите этот (отклоненный) PR: https://github.com/laravel/framework/pull/13566#issue-154985037

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector