Passing Some Argument To The Callback Function Of WinJs Xhr
In Windows 8, I am using WinJs.xhr in a loop to download some content, and as it arrives afterward to the 'done callback', I would like to pass an argument to retrieve the element
Solution 1:
You'll need to capture it in a closure, which with vanilla for loops/iteration is a pain:
for (var k = 0 ; k < 9; k++) {
(function(item) {
var url;
var title = item.name;
if (title != null)
url = monUrl+ title;
WinJS.xhr({ url: url, responseType: "responseXML" }).done(function complete(result) {
// I would like to retrieve the right title here for example
var dataArray = new Array();
var xml = result.responseXML;
/* use your title property here */
});
})(dataArray[k]);
}
Post a Comment for "Passing Some Argument To The Callback Function Of WinJs Xhr"