I want to fetch my data in a textbox by selecting a dropdown select on my view. now here's my table I have this table which populate my dropdown named aircraft_registration_number and when I select one of its data I need to fetch the number or aircraft_id on which row I select and be fetched on the textbox.
So take a look at my table
and here is my controller
public function findPrice(Request $request){
$p = Aircraft::select('aircraft_id')->where('id',$request->id)->first();
return response()->json($p);
}
my Route
Route::get('/admin/aircrafts/findPrice', 'Admin\AircraftsController@findPrice');
my View
{{Form::select('aircraft_registration_number', $aircraft_reg,null,['class' => 'form-control-lg productname', 'placeholder' => 'Select RPC No.'])}}<br>
<br>
{{Form::text('prod_price', '', ['class' => 'form-control','data-dependent'=>'city'])}}
my AJAX/JQuery
<script type="text/javascript">
$(document).ready(function(){
$(document).on('change','.productname',function(){
var prod_id=$(this).val();
var a=$(this).parent();
console.log(prod_id);
var op="";
$.ajax({
type:'get',
url:'{!!URL::to('findPrice')!!}',
data:{'id':prod_id},
dataType:'json',//return data will be json
success:function(data){
console.log("price");
console.log(data.price);
// here price is column name in products table data.coln name
a.find('.prod_price').val(data.price);
},
error:function(){
}
});
});
});
</script>
on my console.logs the error was this

