I am practicing with JQuery .when() function and I receive unexpected results when I use .when with 2 functions that performs ajax calls.
For instance, for single function
$.when(getFolders(id)).then(function(folders) {
/* return value is as expected */
});
Following is the content of folders in this case ,
However, in following case,
$.when(getFolders(idOfClickedFolder), getFiles(idOfClickedFolder))
.then(function( folders, files ) {
/* results formats are not similar here with above one */
});
content of folders is like below, an the actual Folder objects are located inside the first Object of response. I mean I can access the returned JSON object via folders[0].
Following is the getFolders function, getFiles is same as getFolders having different url for ajax.
function getFolders(rootId) {
return $.ajax({
url: '/FileManager/GetFolders/' + rootId,
async: true,
dataType: 'json'
});
}
I am wondering why I am getting the results in two different format.
Thanks.