Here's a simple ajax call wrapped in a method.
MyNS.GetStringList = function (successCallback, failedCallback) {
var methodUrl = serverUrl + "/GetStringList";
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: methodUrl, // Location of the service
data: {}, //Data sent to server
beforeSend: function (XMLHttpRequest) {
//ensures the results will be returned as JSON.
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: successCallback,
error: failedCallback
});
}
Here's a method calling the above method.
function GoGetTheStringList() {
var stringList;
stringList = MyNS.GetStringList(function (data) { return data.d; }, function (XmlHttpRequest, textStatus, errorThrown) {
alert("error");
});
alert(reasonsDictionary); // THIS IS UNDEFINED!
}
What's the proper syntax to make the 1st method return the data.d object?
Thanks as always! Jon