ajax返回数据

在使用远程js验证检测账户是否存在时,直在发请求后返回值无效,怎样把值返回回来呢
重点注意两点

第一点:type不能省略,不能是异步,async: false

第二点:不能在直接请求成功后返回

var res;
$.ajax({
type: "POST",
async: false,
url: '@Url.Content("~/SysManager/UserInfo/IsSameWithOldPassword/?rnd=")' + Math.random(),
data: { password: password },
dataType: "json",
success: function (data) {
res = data.Result;
}
});
return res;

原文地址:https://www.cnblogs.com/huangzhen22/p/4191767.html