I have list of lib name from the name I want fetch the author name. for this I made each loop on library name and make async call. I want return all the author name with library name once the call was end. While I try with Async call it return the call back before the call was successes. so I have try to return the callback in success but now the call back was return once the first request completed. I have try with sync call but it block the user interface. so what is the best method to do that. My code
function FetchLibAuthorID(LibCollection, callback) {
$.each(LibCollection, function (key, value) {
$.ajax({
url: value.MetadataURI + '?$select=schemaXml',
type: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function (data) {
var listProperties = schemaXml2Json(data.d.SchemaXml);
LibCollection[key].AuthorID = listProperties.Author;
LibCollection[key].RootFolder = listProperties.RootFolder;
},
error: function (data2) {
alert('error');
}
});
});
return callback(LibCollection);
}