mardi 26 novembre 2019

Error 500 using AJAX in select Laravel 5.8

I am trying to get the amount of a specific value from the select in my blade. I get Internal 500 error, I can't locate where it goes wrong. Help is highly appreciated!

Route

Route::get('/ajax-amount',function(){
     $id = Input::get('id');
     $amount = RoomType::where('id', $id)->get();

     return Response::json($amount);
});

JS

$("#description").change(function(){
     var id = $("#description").val();
     $.get('/ajax-amount?id=' + id,function(data){
    console.log(data);
     });
});

Blade

<select name="description" id="description" class="form-control">
       <option value="">— Select Room Description —</option>
       @foreach ($types as $type)
           <option value=""></option>
       @endforeach
 </select>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire