I am trying to get some data from my database but I keep getting Error 500.
I can get data from my controller, but when I try to send database info from my controller to the ajax I get an error 500 in Chrome Network
Here is my Controller
public function obtenerEntrada()
{
//get nombre of Entrada by its id
$id=$_GET['id'];
$ent=Entrada::find($id);
//This works
return response()->json(['nombre' => $id]);
//This gives me error 500
//return response()->json(['nombre' => $ent->nombre]);
}
Here is my Route
Route::get('/obtenerEntrada', 'entradasController@obtenerEntrada');
Here is my Blade with Ajax
$.ajax({
url:'obtenerEntrada',
type: 'GET',
data: {
id:idprod
},
success: function( response ){
alert(response.nombre);
},
error: function () {
alert('No se encontro el producto');
}
});
via Ulises Garibay