我有这个代码:
my.data = function () {
var getAuth = function (userName, password) {
var model = JSON.stringify({ "UserName": userName, "Password": password });
var result;
$.ajax({
url: my.baseUrl + "api/AD",
type: "POST",
data: model,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (data) {
result = data;
return result;
}
});
}
return {
getAuth: getAuth
}
}();
当我调用 getAuth 时,我可以看到数据返回“true”,但调用函数 - var result = my.data.getAuth(username,password); 返回未定义。任何想法?