Laravel previous page content loading issue

I am developing a website in Laravel 5, It has a Jobs page where data loaded through ajax which have many filters. When I open a link and come back to the previous page (Jobs page) by clicking the browser back button, it showing me Json data on the browser window instead of loading the whole page.

Laravel previous page content loading issue

Kindly let me know how to solve this issue.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If you’re using the same url for the JSON request as you are for the html request then the browser will simply be returning the last response to that url which will be the JSON data.

There are a few different ways to overcome this but essentially you’ll have to modify your url so that the browser treats them as different responses.

One way would be to append a query string value to the ajax call e.g. ?json.

A slightly more complex yet more flexible approach would be to create separate controllers for your views and JSON data and then prefix your JSON routes with something like /api e.g.

For the view -> Pages/[email protected]

For the json data -> Api/[email protected]

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x