'Make sure only last AJAX result applied [closed]

I use AJAX call for filtering the records. So the the AJAX request is called everytime we click checkbox. When the checkboxes get clicked rapidly, sometimes the result isn't correct since the result applied isn't the last one (async). How can I make sure only the last AJAX result is applied without affecting the performance?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source