dcyilmaz / formajax
FormAjax converts your forms into forms that submit with ajax without refreshing the page.
Installs: 195
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: ^7.3|^8.0
- laravel/framework: ^10.0|^11.0
README
FormAjax is a javascript module that automatically submits your forms. In this way, you do not need to write extra xhr codes at the bottom of each page.
Installation
You can install the package via Composer:
Install package
composer require dcyilmaz/formajax
Publish public
php artisan vendor:publish --tag=public --force
Call the file in footer
<script src="{{ asset('vendor/formajax/formajax.js') }}"></script>
Things to watch out for!
Formajax's return type should be response json
{
status= true|false,
message="string"
}
For example, your method that brings a member in laravel should be like this
public function show(string $id)
{
$user = User::find($id);
return response()->json([
'status' => true,
'message' => view('admin.users.show', compact('user'))->render()
]);
}
Your status code must be 200 in the return type, otherwise the error confirm alert will warn you. You can modify the javascript file for further settings and editing.