I have a search functionality on my app where the table updates whenever the user types on the input box. I have made it working, however, I encountered some weird issue where:
- If I type on the search box fast, I get a 500 (Internal Server
Error).
When I delete the search text by holding the backspace on the keyboard, sometimes, the display table is not updated (it's being updated only once I start searching again).
All records are 4 in total. When I searched "one one" and deletes the search text by holding the backspace keyboard key, I only get 2 records instead of 4, sometimes only 1 record. But if I only press the backspace repeatedly, I get all the records.
If I type normally or delete the search text's character one by one, I don't encounter the issue.
This is my ajax call through jquery:
This is my controller:
This is the method on my model (Applicant::search()) that handles the search: