0

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer. I've already had Route as you said and I tried both window.location.replace({{url('appPage')}}) and window.location.href = "{{URL::to('appPage')}}"; but unfortunately I got the same results.
Now window.location.replace('appPage'); or window.location.replace('appPage'); are working with defined route.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.