我有一个url数组。我喜欢加载它们中的每一个并将内容附加到元素。
var myStrArray = ["http://www.google.de", "http://www.facebook.de", "http://www.lycos.de"];
//Initialize local deferred for myStrArray
var myDeferredArray = [];
for (var i = 0; i < myStrArray; i++)
{
myDeferredArray[i] = $.Deferred();
}
for (var i = 0; i < myStrArray.length; i++)
{
$(element).load(myStrArray, function() {
doSomething();
myDeferredArray[i].resolve();
});
}
return myDeferredArray as single deferred