0
這是我的HTML代碼:事先鍵入的內容和警犬POST請求在Laravel不工作5
<input autocomplete="off" type="text" id="chiefComplaintInput" name="chiefComplaintInp" class="typeahead-chiefcomplaint form-control input-circle-right" placeholder="Chief Complaints">
這是我的jQuery的警犬和預輸入代碼:
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>'
}
});
這是我ahve定義路由:
Route::get('opd/searchChiefComplaints/{queryParam}', '[email protected]');
這是控制器的代碼:
public function searchChiefComplaints(Request $request)
{
// return Response::json($request->get('queryParam'));
return $request->get('queryParam');
}
我想實現的是我想向控制器發送請求並接收JSON作爲響應。卜我有問題,實現它,我不知道在哪裏我的代碼是怎麼了?:(
在谷歌瀏覽器的'網絡'選項卡中使用inspect來分析你的後端請求,你可以在這裏看到一些信息,在你可以在laravel文件夾中分析你的日誌文件,看看有什麼不對。 –
Nopes試圖所有沒有反應 –