[javascript] Wait until all jQuery Ajax requests are done?

I'm using size check when all ajax load completed

_x000D_
_x000D_
function get_ajax(link, data, callback) {_x000D_
    $.ajax({_x000D_
        url: link,_x000D_
        type: "GET",_x000D_
        data: data,_x000D_
        dataType: "json",_x000D_
        success: function (data, status, jqXHR) {_x000D_
            callback(jqXHR.status, data)_x000D_
        },_x000D_
        error: function (jqXHR, status, err) {_x000D_
            callback(jqXHR.status, jqXHR);_x000D_
        },_x000D_
        complete: function (jqXHR, status) {_x000D_
        }_x000D_
    })_x000D_
}_x000D_
_x000D_
function run_list_ajax(callback){_x000D_
    var size=0;_x000D_
    var max= 10;_x000D_
    for (let index = 0; index < max; index++) {_x000D_
        var link = 'http://api.jquery.com/ajaxStop/';_x000D_
        var data={i:index}_x000D_
        get_ajax(link,data,function(status, data){_x000D_
            console.log(index)_x000D_
            if(size>max-2){_x000D_
                callback('done')_x000D_
            }_x000D_
            size++_x000D_
            _x000D_
        })_x000D_
    }_x000D_
}_x000D_
_x000D_
run_list_ajax(function(info){_x000D_
    console.log(info)_x000D_
})
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
_x000D_
_x000D_
_x000D_

Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to jquery

How to make a variable accessible outside a function? Jquery assiging class to th in a table Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Getting all files in directory with ajax Bootstrap 4 multiselect dropdown Cross-Origin Read Blocking (CORB) bootstrap 4 file input doesn't show the file name Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource how to remove json object key and value.?

Examples related to ajax

Getting all files in directory with ajax Cross-Origin Read Blocking (CORB) Jquery AJAX: No 'Access-Control-Allow-Origin' header is present on the requested resource Fetch API request timeout? How do I post form data with fetch api? Ajax LARAVEL 419 POST error Laravel 5.5 ajax call 419 (unknown status) How to allow CORS in react.js? Angular 2: How to access an HTTP response body? How to post a file from a form with Axios