(路由文件)
Route::post('/report/collectorSearch','reportController@collectorSearch');
(刀片文件) Ajax代码
$('#collector_name').change(function(event) {
/* Act on the event */
var collector_id = $(this).val();
$.ajax({
url: '{{URL::to("/report/collectorSearch")}}',
type: 'POST',
data: {
collector_id:collector_id,
_token: $('#Productsignup_token').val()
},
dataType:'json',
success:function(CollectorResponse){
console.log(CollectorResponse);
}
})
});
控制器
public function collectorSearch(Request $request){
$getCollector_id = $request->collector_id;
if ($getCollector_id) {
$searchs = sellproduct::where('collector_id',$getCollector_id)->get();
return response()->json($searchs);
}
}