Oct 23, 2015
7
Level 1
Access JSON response in AJAX success function
I've successfully posted a form with AJAX in laravel. After posting the form, controller returns a JSON response
return response()->json([
"message" => "Success"
]);
I want to access this JSON response in AJAX success function.
$.ajax({
url:route,
type:'POST',
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data:{rating: rating,review:review},
success:function(response){
// Access the JSON response //
}
})
How to do it?
Please or to participate in this conversation.