Published
- 1 min read
laravel ajax post request
The solution for this is noted below
laravel ajax post request
Solution
let route = "{{ route('srcname') }}";
let token = "{{ csrf_token()}}";
$.ajax({
url: route,
type: 'POST',
data: {
_token:token,
name:'name',
email:'email'
phone:'09876767'
},
success: function(response) {
console.log(response)
},
error: function(xhr) {
//Do Something to handle error
}});
}
// laravel web
Route::post('srcname', [Controllername::class, 'filter'])->name('srcname');
// Controller
public function filter(Request $request){ return $request->name ;}
Try other methods by searching on the site. That is if this doesn’t work