folcotandiono's avatar

Good laravel implementation

In laravel, if we want to redirect one page to another page, the most common way is using "a href" then controller will handle the href, in my case, i click a button, then i handle all case like empty or valid email in javascript, then i use ajax to create a link then from the link i will use windows.location to redirect, is it a good way? the reason why i use ajax is all variable that i need to pass is in javascript, and if i use laravel url, it is in php, and i don't know how to convert javascript to php

0 likes
5 replies
Helmchen's avatar

that depends.

there is nothing wrong about using javascript on the frontend

athulpraj's avatar

It's totally ok to use javascript in blade template

If you have lot of front-end functionalities you can totally isolate it using angular or any other front-end feamework.

Snapey's avatar

Why post the same question?

window.location is just loading a new page. Why would you do this if data is missing? Why not just tell the user that the data is missing right there?

You can use this pattern but It just seems over complex.

folcotandiono's avatar

???, i just want to click a button, validate, open a new page, with data send using controller, and i want the most simple way, but i want to do it in javascript..

From my solution above, i use window.location, but before it load new page, it goes to controller where the controller will send the data right? so no data is missing

Please or to participate in this conversation.