Laravel 5: Update record using jQuery & ajax

In case you have missed I have created a post regarding Laravel 5 + Ajax + Jquery CREATE: No page refresh/reload. You may want to look at it first, thought it is not required.

This tutorial is to edit a record and then update it without refreshing the entire page.

You might need little knowledge with jQuery and Ajax also with JSON return.

Note: this tutorial will not include the creation of the index function, but will just tackle a little of it, you should know the basic before proceeding. 

The Route

What we are trying to access is the PUT action, but with Route::resource() that’s come with package.

If you don’t want to use Route::resource() you may use Route::put() for updating your records.

Well either way is good and it’s really up to you.

The Controller

You may have the index your index function that will return the data that will be looped in your table to display records.

For this you will just have simple functions.

  • The index that will return the necessary records to display.
  • The edit which will identify what record to edit, which will then return a json
  • The update that will handle PUT action
Prev1 / 3

Sharing is caring!