1112 0 0 0
Last Updated : 2025-04-28 22:55:48
this snippet will explain how to create ajax requests with laravel specially with forms
to use ajax with laravel you must follow these steps
1- add csrf meta tag to head in your html file
<meta name="csrf-token" content="{{ csrf_token() }}">
2- create your route to use it in the form like this
Route::post("sendMessage", ['uses'=>'MessageController@store', 'as'=>'sendMessage']);
3- create your form and assign your route to form action and specify form method like this
<form class="p-5 bg-white" id="messagingForm" action="{{ route('sendMessage') }}" method="post"> // assigned action and method here
@csrf
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="fname">???
Read Also