How to load ajax responses using Deffered
<p>how to load ajax responses using Deffered. I have page which calls function ajaxCalculate onLoad, which prepares div for ajax results, then calls n of ajax requests which asks for price of products using SOAP,  and it takes much time so I want to deal it asynchronous. (n is number of products). When result will come it should be put to unused div. Ho to do it?
I started it doing in success calback, but it doesn´t worked. Please help me ho to do it with deffered object. I read that it´s better way, but I don´t know ho to do it.</p>

<pre><code>function ajaxCalculate(numberOfProducts) {
        var start = new Date().getTime();
        for (i = 0; i &lt; numberOfProducts; i++) {
            var loadingDiv = '&lt;a href="#" class="list-group-item notloaded"&gt;' +
                '&lt;img src = "img/loading.gif" alt = "loading"&gt;&lt;/a&gt;';
            $(".results").append(loadingDiv);
        }
for (i = 0; i &lt; numberOfProducts; i++) {
        var result = $.ajax({
            url: '/calculations/ajaxCalculate',
            dataType: 'json',
            type: 'POST'
         success: function(){
  $.each(data, function (index, item) {
                console.log(index);
                var result = '&lt;a href="#" class="list-group-item"&gt;' +
                    '&lt;span class="badge"&gt;' + item.price + '€&lt;/span&gt;' + item.name + '&lt;/a&gt;';
                console.log(result);
                $('.results:nth-child(?)').replaceWith(result);
            });
}
        }));
    }
</code></pre>