I usually do most of whats needed in the actual .done() function of any async type calls. But in this case I want to return the string as I need it multiple places but this function returns undefined all the time. The variable is out of scope of the async call so should be available to return no?
var stringIWantBack = function getTableEditorFieldArray(pageName, tableId) {
var searchString = 'webpagename[name ="' + pageName + '"] > tableid[id ="' + tableId + '"] > editor';
var fieldArray;
$.when(datatableUtility.GetInitStringXml())
.done(function (returnedXml) {
fieldArray = $(returnedXml).find(searchString).text();
return fieldArray;
})
.fail(function (jqXhr, textStatus, errorThrown) {
// alert("Error downloading projection data: " + textStatus + " Error: " + errorThrown);
toastr.warning('Error downloading datatable editor fields array: ' + textStatus + ' Error: ' + errorThrown);
});
}