带有JavaScript数组的Xmlhttprequest

带有JavaScript数组的Xmlhttprequest,javascript,xmlhttprequest,Javascript,Xmlhttprequest,我有一个URL数组,例如:[”http://google.com", "http://anothersite.com“] 这是我的密码: var arr = getarray // This is the array above $.get( arr, function(getcode){ console.log(getcode) }); 我需要XMLhttprequest从数组中的链接获取所有信息 这是可能的吗?是的,可以从每个请求中获取延迟对象,并在所有请求都完成时使用$进行处理。当:

我有一个URL数组,例如:
[”http://google.com", "http://anothersite.com“]

这是我的密码:

var arr = getarray // This is the array above

$.get( arr, function(getcode){
console.log(getcode)
});
我需要XMLhttprequest从数组中的链接获取所有信息


这是可能的吗?

是的,可以从每个请求中获取延迟对象,并在所有请求都完成时使用
$进行处理。当
:

var arr = getarray
var promises = arr.map(function(url) {
   return $.get(url);
});

$.when.apply($, promises).then(function() {
   // do something with arguments
   var args = Array.prototype.slice.call(arguments, 0);
   args.forEach(function(responseData, index) {
     // data
   });
});

是的,可以从每个请求中获取延迟对象,并在所有请求都完成时使用
$进行处理。当
:

var arr = getarray
var promises = arr.map(function(url) {
   return $.get(url);
});

$.when.apply($, promises).then(function() {
   // do something with arguments
   var args = Array.prototype.slice.call(arguments, 0);
   args.forEach(function(responseData, index) {
     // data
   });
});

这不仅仅是javascript。请在使用框架时使用正确的标记。这不仅仅是javascript。使用框架时,请使用正确的标记。