I’m gonna show you how to add new records without refreshing the page using Ajax and jQuery in Laravel 5.x.
The are several ways of doing it, you can use also framework such as Angular.js and Vue.js. But for this demonstration I will have to show you the basic way of creating records using ajax.
In this tutorial I will be using offices table.
class Office extends Model
protected $fillable = [
'code', 'name', 'prefix'
Has three fillable fields: ‘code’, ‘name’, ‘prefix’
We will use the resource method in route to prepare all necessary functions as our tutorial progress.
Note: You can use Route:post if you want.