Maintain order of requests when making several ajax callbacks

后端 未结 4 612
名媛妹妹
名媛妹妹 2021-01-05 05:45

I\'m looping through several items and making an ajax request for each of them (using jQuery). I want them to execute independently, but populate into the DOM in the order

4条回答
  •  礼貌的吻别
    2021-01-05 06:29

    I'll be taking a stab in the dark with this one but it might help. Maybe you could create a global buffer array and then whenever the AJAX returns you can add the result to the buffer. You could then set up a timer that, when triggered, will check the contents of the buffer. If they are in order it will output it accordingly.

提交回复
热议问题