【发布时间】:2017-10-14 09:58:52
【问题描述】:
这是我的 HTML 代码:
<input autocomplete="off" type="text" id="chiefComplaintInput" name="chiefComplaintInp" class="typeahead-chiefcomplaint form-control input-circle-right" placeholder="Chief Complaints">
这是我的 Jquery Bloodhound 和预输入代码:
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 作为响应。但是我在实现它时遇到问题我不知道我的代码哪里出错了:(
【问题讨论】:
-
在谷歌浏览器的“网络”标签中使用检查来分析您对后端的请求。你可以在响应部分看到一些信息。您还可以分析 laravel 文件夹中的日志文件,看看有什么问题。
-
Nopes 试过了都没有反应
标签: php jquery laravel-5 typeahead bloodhound