Level 2
I also tried with the get
js
$(document).ready(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#votoGiochi').click(function(){
$.ajax({
url:"{{url('ajax/view_voto/'.$info_giochi->id)}}",
method:"get",
success:function(data){
$('#votehere').html(data);
console.log(data);
$('#votoGiochi').modal("show");
}
});
});
});
route
Route::get('view_voto/{id}', 'AjaxController@view_voto');
controller
public function view_voto(Request $request, $id) {
if(!empty($request)){
$data = VotoGiochi::where('id_gioco', $id)->get();
//print_r($request->all());
return $data;
} else {
return 'asa';
}
}
if I visit the url with the browser it's work:
[{"id":33,"id_gioco":4633,"id_utente":2,"voto":"10","updated_at":"2019-01-03 16:59:56","created_at":"2019-01-03 16:59:56"},{"id":34,"id_gioco":4633,"id_utente":1,"voto":"10","updated_at":"2019-01-05 13:57:24","created_at":"2019-01-05 13:57:24"},{"id":35,"id_gioco":4633,"id_utente":8,"voto":"10","updated_at":"2019-01-12 16:02:22","created_at":"2019-01-12 16:02:22"},{"id":36,"id_gioco":4633,"id_utente":4,"voto":"10","updated_at":"2019-03-18 23:47:55","created_at":"2019-03-18 23:47:55"},{"id":37,"id_gioco":4633,"id_utente":9,"voto":"9","updated_at":"2019-03-19 12:50:36","created_at":"2019-03-19 12:50:36"}]
and the debugbar returns me the correct query
select * from `voto_giochi` where `id_gioco` = '4633'
but why does nothing appear in the modal yet?