Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Make sure only last AJAX result applied

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can send in every request a variable we call "echo".
The echo variable will be declared before request and will be incremented at every request.
The API will send back the echo variable it has received.
You’ll only handle the request which returned the echo value which matches your current echo variable value.
You can disable all buttons until request is done too!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading