i'm using laravel and i want to receive data from jQuery to my controller to insert it to the database , i tried many methodes but without success this is my script :
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }
});
$.ajax({
url:'/test',
type: 'POST',
dataType: 'JSON',
data: {
"name": "Name",
"color": "red",
},
});
and the controller :
public function test()
{
if(Request::ajax()) {
$data = Input::all();
}
dd(json_decode($data));
}
and finally the Route :
Route::post('/test',[
'uses' => 'TagsController@test'
]);