0
我有一個網址的數組。我喜歡加載它們中的每一個,並將內容附加到元素。JQuery加載多個網址,並返回一個延遲結束
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