jQuery Ajax: how to wait until *async* requests success completes before continuing?

后端 未结 2 999
日久生厌
日久生厌 2021-01-12 12:50

I\'m having a problem making ajax fast and functional. Here\'s the pseudo/prototype code:

function blah1(arg1){//arg1 is an array, roughly 10 elemen         


        
2条回答
  •  遥遥无期
    2021-01-12 13:04

    You could make the Ajax call synchronous which you seem to know about, personally I would re factor my code so the success method of the ajax call, then triggers a call off to another function.

    $.ajax({
            //blah options
            async:   true,
            success: function(data){
                arr[i] = data.someInt;
                myCall(arr[i]);
            }//end success
        });//end ajax
    

提交回复
热议问题