I am just migrating from traditional PHP to Laravel framework using the MVC concept. I want to be able to fetch data from the database based on the selection made from a dropdown list box. I keep getting this error: " Sorry, the page you are looking for could not be found. (1/1) NotFoundHttpException ".
See my code: Route File:
Route::get('/process-grpid','PagesController@processgrpid');
my Controller action code:
public function processgrpid($pno){
$pno = $request->get('pno');
$det = Stock::where('itemName',$pno)->get();
return $det;
}
my view page:
<script type="text/javascript">
$(document).ready(function() {
$("select.partno").change(function(){
var selectedPno = $(".partno option:selected").val();
$.ajax(
{
type: "get",
url:"/processgrpid",
data:{pno:selectedPno},
success:function(data){
// var det = JSON.parse(data);
$("#desc").html('<input type="text" placeholder="Enter Item Description" class="form-control" name="descr" required="required"/>');
}
}
);
});
});
</script>
<table>
<tr>
<th>Item Code/Part NO:</th>
<td>
<select name="partno" class="partno form-control">
<option>Select PartNo</option>
<option value="N/A">N/A</option>
@foreach($pstock as $stock)
<option value="{{ $stock->itemName }}">{{ $stock->itemName }}</option>
@endforeach
</select></td>
<th>Description:</th>
<td id="desc"></td></tr>
<tr>
</table>
I don't know what am doing wrong. I have checked stackoverflow, but non of the soution meet my needs. All i wanted is to get the description of stock item from the database based on the dropdown list of partno. Please, help me look and guide me accordingly .