Support the ongoing development of Laravel.io →
posted 10 years ago
Input Forms

I can't seem to find a working example to solve this problem:

I have a view with a form, I need to get data from the DB when user submits the form and update the view without reloading.

My understanding is I need a script that listens for the submit button clicked, passes the data to to controller, the controller gets the data from the DB and returns data in JSON form so that I can use it to fill the view.

Last updated 3 years ago.
0

You could use jQuery or Zepto (many other javascript libs can do it aswell)

Basicly you listen to the submit event of the form (javascript in your case) then prevent it, modify your data (validate aswell) as u wish, then let the prevented event go along, then your laravel project should have a route specified in the form, get the data, validate, handle it with the query builder or with a model, and make a response to the ajax call.

here is a video about it: https://www.youtube.com/watch?v=mMMz-p-N8rs

dont forget to validate your data either in client side and server side.

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

chriz74x chriz74x Joined 8 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.