2015-08-08 64 views
0
var website = ["http://url.com", "http://ebay.com"] 
var array = []; 

$.get(website, function(sourcecode) { 
    array = sourcecode; 
}); 

console.log(sourcecode); 

我需要得到源代碼變量的網站變量內的所有網站的源代碼相結合。不幸的是,一個數組不能與.get一起工作。任何線索我如何解決它?陣列使用jQuery。獲得

回答

0

循環的網址屬性,並將結果推到陣列

var website = ["http://url.com", "http://ebay.com"] 
var array = []; 

for (var i=0;i <website.lenght;i++){ 
    $.get(website[i], function(sourcecode) { 
     array.push(sourcecode); 
    }); 
} 

console.log(sourcecode);