For what you’re showing on your return
'{"empresas_id":"40","tributo_id":4,"mes_referencia":4,"vencimento":"2018-05-10","email":"[email protected]","titulo":"teste666","tributo":{"id":4,"nome":"PIS"},"mesReferencia":{"id":4,"nome":"Abril"},"data_vencimento":"2018-05-10T03:00:00.000Z","valor":1.11}';
If your return is being as returned above then it is already an object, just by getting the attribute, so:
public function inicio( Request $request ){
$retorno = json_decode( $request->input( 'dados' ) );
return response()->json( ["mes" => $retorno->mes_referencia] );
}
The way it is in the example I sent a direct string, it might be your case:
$('.btn').on('click', function(){
clique();
});
function clique(){
$.ajax( {
url : '{{ route('dados') }}',
type : 'post',
dataType: 'json',
data: {
_token : '{{ csrf_token() }}',
dados : '{"empresas_id":"40","tributo_id":4,"mes_referencia":4,"vencimento":"2018-05-10","email":"[email protected]","titulo":"teste666","tributo":{"id":4,"nome":"PIS"},"mesReferencia":{"id":4,"nome":"Abril"},"data_vencimento":"2018-05-10T03:00:00.000Z","valor":1.11}'
},
success: function( data ){
$('.saida').text( data );
}
} );
}
I hope it helps.
You want PHP to read the Laravel result?
– adventistaam
No. This $request is coming in JSON.stringify. I want to know how I dismember it, to get a parameter that’s coming inside it and Josn_decode, it’s not working...
– Carlos B
How the data is really coming in the store method()?
– adventistaam
Is this an ajax request? This Return sends the data to some JS?
– Darlei Fernando Zillmer