Answer the question
In order to leave comments, you need to log in
How to get data sent via ajax without form in laravel?
Good evening. There are two questions:
1) How to get in laravel via $request the data that was sent via ajax without a form? If the data is sent through a form, then we can get it through $request->input(), and without it, what property should we access?
2) Why var_dump($request->ajax()); writes "bool(false)", although after sending the console outputs "XHR finished loading: GET" and the message received from Response::json?
$.ajax({
url: $('#get_route').data('route'),
data: attributeId,
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
type: 'GET',
datatype: 'JSON',
success: function (html) {
console.log(html);
},
error: 'ошибка'
})
public function filter(Request $request)
{
var_dump($request->ajax());
return Response::json(['success' => 'true', 'message' => 'OK']);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question