Verwenden Sie jquery deferreds für eine variable Anzahl von Ajax-Anforderungen

Wenn ich eine variable Anzahl von Ajax-Anfragen habe, wie kann ich sie mit verzögerten Anfragen aufrufen?

meine Vermutung:

//qty_of_gets = 3;

function getHTML(productID, qty_of_gets){

    var dfd = $.Deferred(),
            i = 0,
            c = 0;

    //this is where there could be some magic to 
    //do multiple ajax posts
    //obviously I'm out of my depth here...
    while (i <= qty_of_gets){

        dfd.pipe(function(){
            $.get("queries/html/" + product_id + i + ".php");
        });                       
    i++
    }
    dfd.done(function(){

        while (c <= qty_of_gets){
           $('myDiv').append(c);
           c++;
        }

    });
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage