以下のように約10個のXMLHTTPリクエストを作成したいと思います。i
最初の「子」参照にの値を使用したいのですがi
、コールバックが実行される前に変更されるため、値はi
「結果」タブで取得されたURLと一致しません。これを一般化するにはどうすればよいですか?
var i = 1;
WinJS.xhr({
url: root.results[i].profile_image_url_https,
responseType: 'blob'
}).done(function (result) {
var imgTag = theDiv.children[1].children[0];
var imageBlob = URL.createObjectURL(result.response, {
oneTimeOnly: true
});
imgTag.src = imageBlob; //tempLocalUrl;
});
i = 2;
WinJS.xhr({
url: root.results[i].profile_image_url_https,
responseType: 'blob'
}).done(function (result) {
var imgTag = theDiv.children[2].children[0];
var imageBlob = URL.createObjectURL(result.response, {
oneTimeOnly: true
});
imgTag.src = imageBlob; //tempLocalUrl;
});