function GetDate(value) {
var username;
$.ajax({
type: "post",
url: "ashx/MD5.ashx",
data: "PW=" + value,
success: function (result) {
Encipher = result;
}
});
return Encipher;
}
调用此方法得到的返回值为undefined,是由于Jquery的ajax是异步的,所以大多时候没执行完AJAX就return 了,所以会一直返回undefined,
解决方法:添加async: false,即修改此方法为同步
function GetDate(value) {
var username;
$.ajax({
type: "post",
url: "ashx/MD5.ashx",
data: "PW=" + value,
async: false, //关键是这句
success: function (result) {
Encipher = result;
}
});
return Encipher;
}