tags:

views:

45

answers:

0

So I have this nifty bit of jquery that creates an async ajax call for each url in an array.

My problem is small, I just need to combine those results into one NodeList contained in a global array. From my research .add() should have done the trick, but it doesn't.

I don't want to convert to strings because I want to preform a simple jQuery op before they are combined.

Thanks in advance!

var u = new Array("http:url 1","http:url 2");
var done = u.length;
currentListings = $('p'); //creating a dummy Node so I know I have a NodeList I'm adding too.
var i = 0;

//for each url in the array create an ajax call
$(u).each(function(){

    //create an AJAX call          
    var opts = { 
    url: u[i],
    dataType: "html",
    success: function(data){
            //add retrieved to the data
            var $r = $(data);

            //...process the data a bit....


            //THIS IS MY ISSUE
            //add to the global data holder
            currentListings.add($r); 


            //on the last url, process
            done -= 1;
            if(done == 0) {
                parseResults();
            }
        }
    };
    jQuery.ajax(opts);


    i++;               
});