I'm having a little problem, I've never really used Ajax/Jquery with Laravel before, and I'm having a problem with JQuery $.get() function. I followed a tutorial to make a select input show data from my database on every change. I believe the tutorial was based on laravel 4, and Im using laravel 5.1 I'm stuck at this part:
$.get('/ajax-mascsel?cod_masc=' + cod_masc+, function(data){
console.log(data);
}
This returns the following error on the console:
GET http://localhost/ajax-mascsel?cod_masc=37 500 (Internal Server Error) jquery.min.js:4
Browsing the error, I found out it is a server sided error, and It be caused by a lot of reasons, but the most comon is the csrf_token, my problem here is, I dont know how to solve it function, I know in AJAX you add it in the "header:", but I dont know where in the $.get();
How could I solve this? Also, this is my route processing the ajax request:
Route::get('/ajax-mascsel', function(){
$cod_masc= Input::get('cod_masc');
$mascota = Mascota::where('cod_masc', $cod_masc)->get();
return Response::json($mascota);
});