E
E
erokhin20042020-04-15 06:14:52
JavaScript
erokhin2004, 2020-04-15 06:14:52

Sequential download of images from the server?

gUZwMzqeyiY.jpg
i get an array of id pictures, and then sequentially load pictures by id,
but ajax is asynchronous and the first picture is inserted the one that downloads first,
and if I turn off asynchronous, the pictures are inserted only when the LAST one is loaded
, how can I make them load one by one?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rasschitai, 2020-04-15
@erokhin2004

function load(){
    //обработка аякс запроса, в случае успеха вызываешь еще раз load(),
    //но уже для следующей картинки
}

K
ksnk, 2020-04-15
@ksnk

You can first mark places for insertion, then insert instead of marking.
placeholder - marks a place. You need to check that the empty span is not visible in the carousel, otherwise it will need to be replaced with something invisible.
After loading the image, the constructed div replaces the placeholder.
Somehow so

...
$each(msg, function(index,value){
    var placeholder=$('<span></span>').appendTo('.carousel-inner');
    $.ajax(
...
      if(i==0){
         placeholder.replaceWidth('<div class...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question