我正在尝试进行动态搜索。当用户在输入字段中输入字符时,模型会返回结果。我没有使用此代码返回结果:
//here is my HTLML:
<input type='text' placeholder='Search By Email' class='searchterm' >
//here is my jQuery:
$(".searchterm").keyup(function(e){
var q = $(".searchterm").val();
$.getJSON("searchpeeps",
{
q: q,
},
function(data) {
$("ul.peepList").empty();
$("ul.peepList").append(" Results for <b>" + q + "</b>");
$.each(data.query.search, function(i,item){
$("ul.peepList").append("<li>"++"</li>");
});
});
});
//here is my get route:
Route::get('searchpeeps/{q}', array('as' => 'searchpeeps', 'uses' => 'PeopleController@searchpeeps'));
//here is my controller:
public function searchpeeps($id)
{
$uid = Auth::user()->id;
//$q = Input::get('q');
return Invite::where('email', $id)
->where('user_id', $uid)
->orderBy("created_at", "desc")
->groupBy('email')
->get();
}