Consider the following code:
<div id="output"></div>
var i, item;
var s = "Succeed";
for (i = 0 ; i < s.length ; i++){
item = s[i];
(function(item){
$.get('http://echo.jsontest.com/key/value/one/two').done(function(ret){
$("<p>"+item+"</p>").appendTo($('#output'));
});
})(item);
}
How may I fix it as to get Succeed
in the right order and not in a random one? I want to keep the asynchronous requests .
The are two ways to achieve your goal is to separate async requests with actual drawing.
Separate async requests with actual drawing
Introduce slot system or position index of the received item
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.