vendredi 3 février 2017

Best way to handle form that can be submitted using Ajax or the classic way?

I have a HTML form (written with Blade) that offers the user to subscribe to a newsletter. The request is sent using Ajax. Then I handle it using Laravel and the api middleware group. But if user disables JavaScript, then he or she cannot use the form, obviously nothing happens. I am trying to find a way to make the form work no matter if JavaScript is disabled or not. My first thought was to use the ajax() method from the Request class. But I realized $errors is not passed to the session when using the api middleware group. I thought about not using the api middleware group or having two controllers, one for Ajax requests and another for classic HTTP requests.

I was wondering if someone already faced this challenge?

I am not sure if my question / problem is clear. If you have any question please do not hesitate.

Thank you in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2k3ZLmh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire