You cannot return anything from an AJAX (asynchronous) function. It runs in the background, and the callbacks are called at some point in the future when it's done. By that point your function already returned and is finished.
What you can do is this:
function getTableEditorFieldArray(pageName, tableId) {
var searchString = 'webpagename[name ="' + pageName + '"] > tableid[id ="' + tableId + '"] > editor';
return $.when(datatableUtility.GetInitStringXml()).then(function (returnedXml) {
return $(returnedXml).find(searchString).text();
}).fail(function (jqXhr, textStatus, errorThrown) {
// alert("Error downloading projection data: " + textStatus + " Error: " + errorThrown);
toastr.warning('Error downloading datatable editor fields array: ' + textStatus + ' Error: ' + errorThrown);
});
}
Using .then()
here instead of .done()
will allow you to manipulate the data. The return
there, will be sent to any .done()
methods that you attach later.
For example:
getTableEditorFieldArray('test', 123).done(function(stringIWantBack){
// This will be the value returned from `.then()`
console.log(stringIWantBack);
});