I can't find a working solution for this problem: I want to update a part of my view without reloading it, I have a form that collects the data to be passed to the controller, the controller needs to get the data from the DB and spit out a JSON to the view so that it can be filled with such data.
I tried to adapt this http://tutsnare.com/post-data-using-ajax-in-laravel-5/ but it's not working at all. The data collected is not reaching the controller.
My uderstanding is the javascript part in the view should listen to the click event and send a GET request to the controller, the controller checks if the data is sent through AJAX, gets the data from DB then returns the response in JSON form, the view is then updated. Please, does anyone have a working example or can explain?
return response()->json(['key'=>'value']);. This will return correct response with correct headers for JSON. Reloading or no reloading the page is all done in JavaScript. You send AJAX request to controller and get JSON response, then you have to populate the view with data your self, using whatever JS code you need.