I'm having trouble retrieving the data sent by my ajax to laravel
.
My ajax
looks like this:
var id = $(this).siblings(':hidden').val(),
qtd = $(this).val(),
dataUser = { "id": id, "qtd": qtd};
$.ajax({
type: 'POST',
data: {'rel':dataUser},
url: window.location.href + "/atualiza",
success: function (e) {
alert(e);
}
});
And in my controller
it looks like this:
public function atualizaQtd(){
$arr = json_decode($_POST['rel'], true);
return $arr;
}
And so my route:
Route::post('/carrinho/atualiza', [
'uses' => 'CartController@atualizaQtd',
'as' => 'carrinho.atualiza'
]);
I need to access the data of id
and qtd
la in my controller
to perform an activity.
How do I do this? I tried to receive using the Requests
method and I also could not.
When doing no error, it just does not return anything.