I need to find the data coresponding to a specific id, i keep getting this error, i tried dump the id value and it shows NULL
, no idea why, here is code :
Controller :
function fetchdata(Request $request)
{
$id = $request->get('ID');
$req = Demo::find($id);
$output = array(
'reponse' => $req->reponse,
);
echo json_encode($output);
}
View :
$(document).on('click', '.req_reponse', function(){
var id = $(this).attr("ID");
$('#form_output').html('');
$.ajax({
url:"",
method:'get',
data:{id:id},
dataType:'json',
success:function(data)
{
$('#reponse').val(data.reponse);
$('#ID').val(id);
$('#studentModal').modal('show');
}
})
});
Error :
'reponse' => $req->reponse,
"Trying to get property of non-object"
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire