【发布时间】:2011-11-18 06:01:11
【问题描述】:
我需要从 ajax 成功函数的结果中向我的 alert() 返回 true 或 false。但是,我遇到了问题,因为 alert() 结果始终是“未定义”...关于如何解决此问题的任何想法?
我有 DoAjax 作为它自己的函数,因为我在 .js 文件中多次调用它。
var val = '12345';
alert( DoSerialVerification( val ) ); //this returns 'undefined' regardless of cType.length
function DoSerialVerification( piVal ){
var fSuccess = function( oData ){
var cType = oData.type
if( cType.length > 0 ){
alert( cType ); //with piVal = 12345 cType will return 'MODULE'
$('#dialog-1').attr('type', cType);
return true;
} else {
return false;
}
};
DoAjax({ Action: "DoSerialVerification", Value: piVal }, fSuccess );
}
function DoAjax( pAjaxParams, pSuccess ){
$.ajax({url : 'procedures?',
data : pAjaxParams,
async : false,
type : "POST",
dataType : "json",
error : function(oD,oT,oE){ alert( oD+'\n'+oT+'\n'+oE ) },
success : pSuccess
});
}
【问题讨论】:
-
您确认
procedures?正在返回数据吗? -
@IAbstractDownVoteFactory - 是的程序正在返回“模块”