Keep a variable to determine the ajax call order number, for example. 1 for the first call, 2 for the second call, 3 for the ajax call for the third letter. And whenever the ajax request is completed, check the current string length of the value of your input field. If they match, the data is valid, write them on your page, and then reject.
Example: an ajax request with a value of 3 is completed, the current value in the input field = "hou", since hou.length == 3, this is a correct match, and the data can be processed.
source
share