拨打多个ajax电话

 $.ajax({
        url: "",
        jsonpCallback: 'item',
        contentType: "application/json",
        dataType: 'jsonp',

        success: function(data) {
            console.log(data);
            var markup = "";
            $.each(data.list, function(i, elem) {
                dbInsert(elem['itemCode'], elem['description'], elem['price']);
            });

        },
        error: function(request, error) {
            alert(error);
        }
    });

I have the above type of different ajax calls with different urls. How can I run each Ajax call, one after another?

Keep track of the urls still to send, and have the success inline function of one ajax request go and call the next.

var urls = [...];
var runNextAjax = function() {
    var url = urls.pop();
    $.ajax({
        url: url,
        ... other settings, as before ...
        success: function(data) {
           ... do what you want with the data ...
           if (urls.length > 0) runNextAjax();
        },
        error: function(req, err) {
           ... do what you want with the error ...
           if (urls.length > 0) runNextAjax();
        }
    });        
};
// Start the sequence off.
runNextAjax();

The above code acts on the data as it arrives, if you want to cache it all and act on it all at the end, store each result in an array, then process the array in a function that gets called at the end:

var dataAccumulator = [];
var displayAllData = function() {
    for (int i = 0; i < dataAccumulator.length; ++i) {
        var data = dataAccumulator[i];
        ... process the data into HTML as before ...
    }
};

var urls = [...];
var runNextAjax = function() {
    var url = urls.pop();
    $.ajax({
        url: url,
        ... other settings, as before ...
        success: function(data) {
           // Store the data we received
           dataAccumulator.push(data);
           if (urls.length > 0) runNextAjax();
           else displayAllData();
        },
        error: function(req, err) {
           ... do what you want with the error ...
           if (urls.length > 0) runNextAjax();
           else displayAllData();
        }
    });        
};

// Start the sequence off.
runNextAjax();

You can do something like this.

$('#button').click(function() {
    $.when(
        $.ajax({
            url: '/echo/html/',
            success: function(data) {
                alert('one is done')
            }
        }),
        $.ajax({
            url: '/echo/html/',
            success: function(data) {
                alert('two is done')
            }
        })
    ).then( function(){
        alert('Final Done');
    });
});

fiddle