What is Ajax and how does Ajax search work?
Every time a user enters more characters into the search field, a new request is sent to the server. A typical Ajax search will work with the “input” event which is fired after the value from a form element is changed.
Ajax search vs. regular search
Based on the information above it looks like the Ajax search is a great replacement for the regular search. Sure, there are a lot of advantages:
- Basic form field validation without a server request
- Frontend and backend code are separated
- The search is faster and more user friendly
- Combine form element values without reloading the page
- Using Ajax search on static websites
But there are also disadvantages, like:
- Accessibility issues, because the response is loaded dynamically into the HTML structure
- Server side data validation is still necessary
- The browser back button doesn’t bring you back to the previous search result (compared to a result page with a query string inside the URL)
- A higher server load because a new request is submitted with every character typed in the search form
- You can’t create a (cached) pages for search results.
Which of both search interfaces is best, depends on your website and how visitors use your search function. Check your Ajax live search on different devices like iPads and cell phones. The search might not work for users on small screens.