I am making a website using laravel. I have a search page where users can search for products and a SearchController which does the actual searching.
Right now, I am passing the form data to the controller with a post method (search string, filters, etc.), it works brilliantly!
However, I see that almost every website passes the search parameters in the URI using a query string. Why is tht better? Should I be doing the same?
Thanks!
2
Answers
It’s good to keep query parameters in uri for SEO purpose. If you use post method, when you refresh page you won’t get data. If you use get method, even page is refreshed you will get data. If you pass query in uri, you can directly get the data by accessing that url.
The search parameter in URL is helpful when the user wants to search more item related to that without refreshing the page. You can do it by ajax and php.