Typeahead remote with Laravel 4 - Individual pieces working I think, but not working together

自作多情 提交于 2019-12-04 17:16:06

Try taking var_dump out of the controller - typeahead is expecting valid JSON as a response.

user2963630

This will work and tested:

$data = array();

$results = Student::select ('id')->where('id', 'LIKE',$query . '%')->get();
foreach ($results as $result):
    $data[] = $result->id."";
endforeach;
return Response::json($data);

By the way, you could have done

$results = Ingredient::select ('name')->where('name', 'LIKE', '%' . $query . '%')->        

return Response::json($results);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!