PHP - AJAXLesson 80Free preview
AJAX Live Search
This lesson is part of PHP · All levels
Summary
Live search displays search results suggestions as soon as the user types, without the need to press a button or reload the page. Each entry triggers an AJAX request to the PHP endpoint that sends a list of results, and then the result is rendered to a div. To keep the server from overloading, apply a minimum of character limits and a technique of debounce.
Key points
- Type on the input to trigger the AJAX request to the PHP file searcher.
- Debounce delayed the request a few hundred milliseconds to not send per letter.
- Results are displayed on a dedicated div that is updated via DOM.
- Give a keyword length limit and a result limit (LIMIT).
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.