While loop with jQuery async AJAX calls

前端 未结 3 1120
猫巷女王i
猫巷女王i 2020-12-03 06:09

The thing: I have a page, which has to display undetermined number of images, loaded through AJAX (using base64 encoding on the server-side) one by one.

var          


        
3条回答
  •  一整个雨季
    2020-12-03 06:48

    Try using setInterval() function instead of while().

    var fetch = setInterval(loadImage, 2000);
    
    function loadImage(){
        position= new position; //Change variable position here.
        getImageRequest(position);
        if(!GLOB_PROCEED_FETCH){
              clearInterval(fetch);
        }
    }
    

提交回复
热议问题