Question on AJAX/Twitch API

Question on AJAX/Twitch API
0

#1

May I know how do I get the same order of icons and data in a designated order everytime without setting async to false? Because as I understand that defeats the purpose of using AJAX in the first place. They keep returning in a random order each time the page is refreshed.

Any help is appreciated.


#2

Note: As contrasted with iterating over an array’s indices in a numerically ordered way (for loop or other iterators), the order of iteration over an object’s properties is not guaranteed and may vary between different JS engines. Do not rely on any observed ordering for anything that requires consistency among environments, as any observed agreement is unreliable.

Source (See the first note here).


#3

There is no way to guarantee that you’ll receive data in the same order you requested it. The time differences come down to things happening outside of the client’s, and even the server’s, control. The best you can do is change the order of the data when you get it in, which requires waiting for all of it to finish before displaying. I don’t suggest this unless there’s some actual reason you need the users to be in a particular order (and even then, just modify your view logic before messing with your AJAX code).