【发布时间】:2011-08-17 14:34:57
【问题描述】:
$("#submit").click(function () {
var boolError = false;
CheckForm("#email");
CheckPhone("#phone");
if (boolError == true) {
console.log('error');
} else {
console.log('here');
// $("#form").submit();
}
});
问题是它总是返回console.log('here');
有没有办法等待 CheckForm 和 CheckPhone。来自 CheckForm 函数的 AJAX 调用:
$.ajax({
type: "POST",
url: "/webservice/user.asmx/CheckForm",
data: "{'type':'" + var_type + "', 'value':'" + var_value + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) { },
success: function (data) {
var obj = data.d;
}
});
【问题讨论】: