I have searched this site and tried, but I am still not coming right. I have searched these threads (among others):
How to get return value in a function with inside Ajax call - JQuery
get return value of jQuery get().done() function
I have one page on my app. I have one dxSelectBox
on my page. I need to display a list of depots inside the dxSelectBox
. My Webservice works. I am trying this to show the results in the dxSelectBox
but it does not show anything:
App.FirstScreen = function (params) {
// "use strict";
var viewModel = {
dsDepots: ko.observableArray([]),
GetDepots: getDepots (),
};
return viewModel;
};
function getDepots() {
// this will generate another thread to run in another function
jQuery.ajax({
url: 'connection_string + "/rest/_getDepots"',
type: 'get',
success: function (data) {
if (data != "") {
var _result = JSON.parse(data.childNodes['0'].childNodes['0'].data);
viewModel.dsDepots(_result);
}
return (data);
},
error: function () {
return "Hello";
}
});
}