kbrk
kbrk

Reputation: 660

Call url from view in Laravel

I'm learning Laravel framework. In my application I'm sending an ajax request and then I want to call another page from success. I've already tried some suggestions but I 've got errors.

I'm using ES6 and my jsx files are converted to js file to public/js directory.

resources/assets/js/ is es6 directory and resources/views/appPage.blade.php is view file

I also created appPage.blade.php file in public directory but this didn't work.

I post the trials and their resulst in comment line

 success: function success(response) {
                    if (response.result) {

                        // Request Url: http://localhost:8000/appPage
                        // Status code: 404
                        //window.location.replace('appPage');
                        //window.location.href = 'appPage';

                        // Request Url: http://localhost:8000/%7B%7Burl(%22appPage%22)%7D%7D
                        // Status code: 404
                        //window.location.href = '{{url("appPage")}}';
                    }
                }

Any suggestions ? Thank you.

Upvotes: 0

Views: 3745

Answers (1)

Raymond Cheng
Raymond Cheng

Reputation: 2505

you don't need create view file in public folder,

{{ url("appPage") }} should be a route path that already exists

define a route in app/Http/routes.php that url is appPage, like this :

Route::get('appPage', function(){

   return view('appPage');
});

i think you need get more tutorials. laracasts have a lots of tutorials.

Upvotes: 2

Related Questions